UIView(UIViewAnimationWithBlocks)

来源:互联网 发布:类似forest的软件 编辑:程序博客网 时间:2024/05/29 12:27

还是老规矩, 直接看API。

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

这里其他参数就说了,就看下UIViewAnimationOptions 这个枚举

typedef NS_OPTIONS(NSUInteger, UIViewAnimationOptions) {

    UIViewAnimationOptionLayoutSubviews            = 1 <<  0,

    UIViewAnimationOptionAllowUserInteraction      = 1 <<  1, // turn on user interaction while animating

    UIViewAnimationOptionBeginFromCurrentState     = 1 <<  2, // start all views from current value, not initial value

    UIViewAnimationOptionRepeat                    = 1 <<  3, // repeat animation indefinitely

    UIViewAnimationOptionAutoreverse               = 1 <<  4, // if repeat, run animation back and forth

    UIViewAnimationOptionOverrideInheritedDuration = 1 <<  5, // ignore nested duration

    UIViewAnimationOptionOverrideInheritedCurve    = 1 <<  6, // ignore nested curve

    UIViewAnimationOptionAllowAnimatedContent      = 1 <<  7, // animate contents (applies to transitions only)

    UIViewAnimationOptionShowHideTransitionViews   = 1 <<  8, // flip to/from hidden state instead of adding/removing

    UIViewAnimationOptionOverrideInheritedOptions  = 1 <<  9, // do not inherit any options or animation type

    

    UIViewAnimationOptionCurveEaseInOut            = 0 << 16, // default

    UIViewAnimationOptionCurveEaseIn               = 1 << 16,

    UIViewAnimationOptionCurveEaseOut              = 2 << 16,

    UIViewAnimationOptionCurveLinear               = 3 << 16,

    

    UIViewAnimationOptionTransitionNone            = 0 << 20, // default

    UIViewAnimationOptionTransitionFlipFromLeft    = 1 << 20,

    UIViewAnimationOptionTransitionFlipFromRight   = 2 << 20,

    UIViewAnimationOptionTransitionCurlUp          = 3 << 20,

    UIViewAnimationOptionTransitionCurlDown        = 4 << 20,

    UIViewAnimationOptionTransitionCrossDissolve   = 5 << 20,

    UIViewAnimationOptionTransitionFlipFromTop     = 6 << 20,

    UIViewAnimationOptionTransitionFlipFromBottom  = 7 << 20,

} NS_ENUM_AVAILABLE_IOS(4_0);


+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion NS_AVAILABLE_IOS(4_0);// delay = 0.0, options = 0


+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animationsNS_AVAILABLE_IOS(4_0); // delay = 0.0, options = 0, completion = NULL


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


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


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


/* Performs the requested system-provided animation on one or more views. Specify addtional animations in the parallelAnimations block. These additional animations will run alongside the system animation with the same timing and duration that the system animation defines/inherits. Additional animations should not modify properties of the view on which the system animation is being performed. Not all system animations honor all available options.

 */

+ (void)performSystemAnimation:(UISystemAnimation)animation onViews:(NSArray *)views options:(UIViewAnimationOptions)options animations:(void (^)(void))parallelAnimations completion:(void (^)(BOOL finished))completionNS_AVAILABLE_IOS(7_0);


针对以上block 里面可以套用, 来完成连续动画。




0 0