IOS动画实现(3)UIView封装的动画

苹果官网文档

UIView触发动画的方式分为两类,打开UIView.h头文件可以看到两个UIView的Category,

@interface UIView(UIViewAnimation) 以及 @interface UIView(UIViewAnimationWithBlocks)

两种动画的方式就在此了。姑且命名为commit方式block方式。两种实现方式,效果大同小异,只是代码实现不同而已。

文档里面描述的,可以动画起来的属性有以下七种

@"frame",@"bounds",@"center",@"transform",@"alpha",@"backgroundColor",@"contentStretch"

也各自提供了一些特效的接口。

比如:

需要重复动画commit方式有提供setAnimationRepeatCount,而block方式有UIViewAnimationOptionRepeat。

finish的回掉commit方式有setAnimationDidStopSelector,而block方式设置finish的block即可。

相应的stopAnimation,也都可以通过[view.layer removeAllAnimations]来实现

 

对应的代码在github上有。地址如下:

https://github.com/boboxu/ios

 

原文地址:https://www.cnblogs.com/bobox/p/4811754.html