iOS动画之UIView动画使用

  • UIView头尾式动画
  • UIView的block动画
1,UIView头尾式动画
//这种方式的动画在iOS 4之后就不建议使用了,现在可以之后block方式动画,之后会讲到
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:3];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDelegate:self];

//需要做的动画操作
CGRect frame =  self.imageView.frame;
frame.origin.y  += 200;
self.imageView.frame = frame;

[UIView commitAnimations];
2, UIView的block基本动画
//方式一:动画属性是可以在block中直接设置的
[UIView animateWithDuration:2 animations:^{
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    CGRect frame =  self.imageView.frame;
    frame.origin.y  += 200;
    self.imageView.frame = frame;
}];

//方式二:
[UIView animateWithDuration:2 animations:^{
    //动画内容
} completion:^(BOOL finished) {
    //动画完成操作
}];

//方式三:
[UIView animateWithDuration:2 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
    //动画内容
} completion:^(BOOL finished) {
    //动画完成操作
}];

//其实后面还有其他几种方式,如果有需要可以自己查看下,没什么难点,所以不再赘述
2, UIView的block转场动画
  • 不过这种block转场动画比较有限,只封装了其中的几种
//UIView封装的专场动画
[UIView transitionWithView:_imImageView duration:2 options:UIViewAnimationOptionTransitionFlipFromTop animations:^{
} completion:^(BOOL finished) {
}];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容