您的位置:首页 > 产品设计 > UI/UE

UIView Animation

2016-04-24 15:37 399 查看
@interface UIView(UIViewAnimation)

+ (void)beginAnimations:(nullable
NSString *)animationID context:(nullable
void *)context;
// additional context info passed to will start/did stop selectors. begin/commit can be nested

+ (void)commitAnimations;
// starts up any animations when the top level animation is commited

// no getters. if called outside animation block, these setters have no effect.

+ (void)setAnimationDelegate:(nullable
id)delegate;
// default = nil

+ (void)setAnimationWillStartSelector:(nullable
SEL)selector;
// default = NULL. -animationWillStart:(NSString *)animationID context:(void *)context

+ (void)setAnimationDidStopSelector:(nullable
SEL)selector;
// default = NULL. -animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context

+ (void)setAnimationDuration:(NSTimeInterval)duration;
// default = 0.2

+ (void)setAnimationDelay:(NSTimeInterval)delay;
// default = 0.0

+ (void)setAnimationStartDate:(NSDate *)startDate;
// default = now ([NSDate date])

+ (void)setAnimationCurve:(UIViewAnimationCurve)curve;
// default = UIViewAnimationCurveEaseInOut

+ (void)setAnimationRepeatCount:(float)repeatCount;
// default = 0.0. May be fractional

+ (void)setAnimationRepeatAutoreverses:(BOOL)repeatAutoreverses;
// default = NO. used if repeat count is non-zero

+ (void)setAnimationBeginsFromCurrentState:(BOOL)fromCurrentState;
// default = NO. If YES, the current view position is always used for new animations -- allowing animations to "pile up" on each other. Otherwise, the last end state is used for the animation (the default).

+ (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache;
// current limitation - only one per begin/commit block

+ (void)setAnimationsEnabled:(BOOL)enabled;
// ignore any attribute changes while set.

+ (BOOL)areAnimationsEnabled;

+ (void)performWithoutAnimation:(void (^)(void))actionsWithoutAnimation
NS_AVAILABLE_IOS(7_0);

+ (NSTimeInterval)inheritedAnimationDuration
NS_AVAILABLE_IOS(9_0);

@end

@interface UIView(UIViewAnimationWithBlocks)

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

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

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

/* Performs `animations` using a timing curve described by the motion of a spring. When `dampingRatio` is 1, the animation will smoothly decelerate to its final model values without oscillating. Damping ratios less than 1 will oscillate more and more before
coming to a complete stop. You can use the initial spring velocity to specify how fast the object at the end of the simulated spring was moving before it was attached. It's a unit coordinate system, where 1 is defined as travelling the total animation distance
in a second. So if you're changing an object's position by 200pt in this animation, and you want the animation to behave as if the object was moving at 100pt/s before the animation started, you'd pass 0.5. You'll typically want to pass 0 for the velocity.
*/

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

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

+ (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options
completion:(void (^
__nullable)(BOOL finished))completion
NS_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<__kindof
UIView *> *)views options:(UIViewAnimationOptions)options animations:(void (^
__nullable)(void))parallelAnimations completion:(void (^
__nullable)(BOOL finished))completion
NS_AVAILABLE_IOS(7_0);

@end

@interface UIView (UIViewKeyframeAnimations)

+ (void)animateKeyframesWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewKeyframeAnimationOptions)options
animations:(void (^)(void))animations completion:(void (^
__nullable)(BOOL finished))completion
NS_AVAILABLE_IOS(7_0);

+ (void)addKeyframeWithRelativeStartTime:(double)frameStartTime relativeDuration:(double)frameDuration
animations:(void (^)(void))animations
NS_AVAILABLE_IOS(7_0);
// start time and duration are values between 0.0 and 1.0 specifying time and duration relative to the overall time of the keyframe animation

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: