透明度、旋转动画

来源:互联网 发布:无线信道软件 ios 编辑:程序博客网 时间:2024/06/04 19:51
        <span style="color:#ff0000;">application.applicationIconBadgeNumber = 2;</span>        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(50, 60, 90, 90)];    view.tag = 101;    view.backgroundColor = [UIColor redColor];    [self.window addSubview:view];        //设置一个按钮    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];    button.frame = CGRectMake(10, 30, 40, 30);    button.backgroundColor = [UIColor greenColor];    //添加一个点击事件    [button addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];    [self.window addSubview:button];        return YES;}- (void)buttonAction{    //取得视图    UIView *view = [self.window viewWithTag:101];        //1.移动动画    /*//    view.frame.origin.x = 90;     x.y的值是只读的    CGRect frame = view.frame;        frame.origin.x = 190;//    view.frame = frame;    //开启动画    [UIView beginAnimations:@"animation1" context:NULL];    //设置动画的时间    [UIView setAnimationDuration:2];    //设置延迟时间    [UIView setAnimationDelay:3];    //设置动画重复的次数    [UIView setAnimationRepeatCount:3];        view.frame = frame;        //关闭动画    [UIView commitAnimations];     */      <span style="color:#ff0000;">  //2.透明度.旋转</span>    //开启动画    view.alpha = 1;    [UIView beginAnimations:@"animation1" context:NULL];    //设置动画的时间    [UIView setAnimationDuration:2];    //设置重复次数    [UIView setAnimationRepeatCount:3];    //设置延迟动画的时间//    [UIView setAnimationDelay:1];    //设置加速方式    /*     UIViewAnimationCurveEaseInOut,         // slow at beginning and end     UIViewAnimationCurveEaseIn,            // slow at beginning     UIViewAnimationCurveEaseOut,           // slow at end     UIViewAnimationCurveLinear     匀速     */    [UIView setAnimationCurve:UIViewAnimationCurveLinear];        //设置代理对象    [UIView setAnimationDelegate:self];    //设置动画结束后调用的方法    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];    //    view.alpha = 0;    view.transform = CGAffineTransformRotate(view.transform, M_PI/1.1);        //关闭动画    [UIView commitAnimations];    }//动画结束以后调用的方法- (void)animationDidStop:(NSString *)animationID   //动画的名字                finished:(NSNumber *)finished                 context:(void *)context{    NSLog(@"动画结束了");}

0 0
原创粉丝点击