标签:
运用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
标签:
原文地址:http://www.cnblogs.com/beddup/p/4614652.html