码迷,mamicode.com
首页 > 移动开发 > 详细

iOS开发总结(A0)- UIView Animation

时间:2015-07-01 23:23:08      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

运用uiview的几个animation方面可以使动画变的更加简单

1. 如果是view properties 的变化,使用以下方法

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion; 

+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion; 

+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations;

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion;

可以用作animation的properties有:frame,bounds,center,alpha, transform(setTransform),bkgcolor

如果options中有repeat 选项,那么该如何停止动画呢?

可用[self.layer removeAllAnimations];停止动画

更多控制,设置 CAMediaTiming中properties(可参考http://www.cnblogs.com/gaoxiao228/archive/2013/01/28/2880285.html)

 

2. 如果是view 的hierachy 变化,使用以下方法:

+ (void)transitionWithView:(UIView *)view duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion ;

+ (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion;
 // toView added to fromView.superview, fromView removed from its superview

 

iOS开发总结(A0)- UIView Animation

标签:

原文地址:http://www.cnblogs.com/beddup/p/4614652.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!