IOS中实现动画的三种方式

来源:互联网 发布:js thread.sleep 编辑:程序博客网 时间:2024/06/09 21:06

无论是Android和IOS开发动画的使用是少不了的,Android中可以实现各种各样的动画效果,IOS通用可以做的到:

接下来让我介绍下实现动画的三种方式:

方式一:

开始动画

 [UIView beginAnimations:nil context:nil];

设置动画的持续时间
       [UIView setAnimationDuration:1.0];

执行动画的代码
    itemView.frame=CGRectMake(0, 44, 320, 50);
      itemView.alpha=1;

结束动画
       [UIView commitAnimations];
方法二:使用一个block来写的

[UIView animateWithDuration:1.0 animations:^{

//执行动画的代码
     itemView.frame=CGRectMake(0, 44, 320, 50);
           itemView.alpha=1;    }];
方法三:

 [UIView animateWithDuration:animateDuration animations:^{

//执行动画的代码
        itemView.frame=CGRectMake(0,rowY, 320, 40);
        itemView.alpha=1;
    } completion:^(BOOL finished) {

//动画结束后要执行的代码
        NSLog(@"动画结束");
    }];

0 0
原创粉丝点击