此处是.h.h.h.h.h.h.h.h.h.h..hh.h.
//
// Created by wll on 2019/2/21.
// Copyright © 2019 wll. All rights reserved.
// 轻量级动画处理类
#import
@interface UIView (animation)
/**
下拉展示效果动画 默认动画时间0.25s
*/
- (void)pullShowAnimation;
/**
上拉关闭动画效果 默认动画时间0.25s
*/
- (void)pushHideAnimationWithFinishBlk:(void(^)(UIView * view))finishBlk;
/**
下拉展示效果动画
*/
- (void)pullShowAnimationWithDuration:(CFTimeInterval)duration;
/**
上拉关闭动画效果
*/
- (void)pushHideAnimationWithDuration:(CFTimeInterval)duration finishBlk:(void(^)(UIView * view))finishBlk;
/**
上拉展示动画效果 默认动画时间0.25s
*/
- (void)pushShowAnimation;
/**
上拉展示动画效果
*/
- (void)pushShowAnimationWithDuration:(CFTimeInterval)duration;
/**
下拉关闭效果动画 默认动画时间0.25s
*/
- (void)pullHideAnimationWithFinishBlk:(void(^)(UIView * view))finishBlk;
/**
下拉关闭效果动画
*/
- (void)pullHideAnimationWithDuration:(CFTimeInterval)duration finishBlk:(void(^)(UIView * view))finishBlk;
/**
模仿系统弹框展示动画 默认动画时间0.25s
*/
- (void)systemAlertShowAnimation;
/**
模仿系统弹框展示动画
*/
- (void)systemAlertShowAnimationWithDuration:(CFTimeInterval)duration;
/**
模仿系统弹框关闭动画 默认动画时间0.25s
*/
- (void)systemAlertHideAnimationWithFinishBlk:(void(^)(UIView * view))finishBlk;
/**
模仿系统弹框关闭动画
*/
- (void)systemAlertHideAnimationWithDuration:(CFTimeInterval)duration finishBlk:(void(^)(UIView * view))finishBlk;
@end
@interface CALayer (animation)
@property (nonatomic, assign) CGPoint originalAnchorPoint;
@property(nonatomic,assign)CGPointoriginalPosition;
@property (nonatomic, copy) void(^finishBlk)(CALayer * layer);
/**
下拉展示效果动画 默认动画时间0.25s
*/
- (void)pullShowAnimation;
/**
上拉关闭动画效果 默认动画时间0.25s
*/
- (void)pushHideAnimationWithFinishBlk:(void(^)(CALayer * layer))finishBlk;
/**
下拉展示效果动画
*/
- (void)pullShowAnimationWithDuration:(CFTimeInterval)duration;
/**
上拉关闭动画效果
*/
- (void)pushHideAnimationWithDuration:(CFTimeInterval)duration finishBlk:(void(^)(CALayer * layer))finishBlk;
/**
上拉展示动画效果 默认动画时间0.25s
*/
- (void)pushShowAnimation;
/**
上拉展示动画效果
*/
- (void)pushShowAnimationWithDuration:(CFTimeInterval)duration;
/**
下拉关闭效果动画 默认动画时间0.25s
*/
- (void)pullHideAnimationWithFinishBlk:(void(^)(CALayer * layer))finishBlk;
/**
下拉关闭效果动画
*/
- (void)pullHideAnimationWithDuration:(CFTimeInterval)duration finishBlk:(void(^)(CALayer * layer))finishBlk;
/**
模仿系统弹框展示动画 默认动画时间0.25s
*/
- (void)systemAlertShowAnimation;
/**
模仿系统弹框展示动画
*/
- (void)systemAlertShowAnimationWithDuration:(CFTimeInterval)duration;
/**
模仿系统弹框关闭动画 默认动画时间0.25s
*/
- (void)systemAlertHideAnimationWithFinishBlk:(void(^)(CALayer * layer))finishBlk;
/**
模仿系统弹框关闭动画
*/
- (void)systemAlertHideAnimationWithDuration:(CFTimeInterval)duration finishBlk:(void(^)(CALayer * layer))finishBlk;
@end
.m.m.m.m.m.m.m.m.m.m.m.m.m.m.m.m.m.
//
// Created by wll on 2019/2/21.
// Copyright © 2019 wll. All rights reserved.
//
#import"BLTAnimationManager+.h"
#import
#define kAnimationDuration 0.25
@implementation UIView (animation)
/**
下拉展示效果动画 默认动画时间0.25s
*/
- (void)pullShowAnimation {
[self.layerpullShowAnimationWithDuration:kAnimationDuration];
}
/**
上拉关闭动画效果 默认动画时间0.25s
*/
- (void)pushHideAnimationWithFinishBlk:(void(^)(UIView * view))finishBlk {
__weaktypeof(self) weakSelf =self;
[self.layerpushHideAnimationWithDuration:kAnimationDurationfinishBlk:^(CALayer*layer) {
__strong typeof(self) strongSelf = weakSelf;
!finishBlk?:finishBlk(strongSelf);
}];
}
/**
下拉展示效果动画
*/
- (void)pullShowAnimationWithDuration:(CFTimeInterval)duration {
[self.layerpullShowAnimationWithDuration:duration];
}
/**
上拉关闭动画效果
*/
- (void)pushHideAnimationWithDuration:(CFTimeInterval)duration finishBlk:(void(^)(UIView * view))finishBlk {
__weaktypeof(self) weakSelf =self;
[self.layerpushHideAnimationWithDuration:durationfinishBlk:^(CALayer*layer) {
__strong typeof(self) strongSelf = weakSelf;
!finishBlk?:finishBlk(strongSelf);
}];
}
/**
上拉展示动画效果 默认动画时间0.25s
*/
- (void)pushShowAnimation {
[self.layerpushShowAnimationWithDuration:kAnimationDuration];
}
/**
上拉展示动画效果
*/
- (void)pushShowAnimationWithDuration:(CFTimeInterval)duration {
[self.layerpushShowAnimationWithDuration:duration];
}
/**
下拉关闭效果动画 默认动画时间0.25s
*/
- (void)pullHideAnimationWithFinishBlk:(void(^)(UIView * view))finishBlk {
__weaktypeof(self) weakSelf =self;
[self.layerpullHideAnimationWithDuration:kAnimationDurationfinishBlk:^(CALayer*layer) {
__strong typeof(self) strongSelf = weakSelf;
!finishBlk?:finishBlk(strongSelf);
}];
}
/**
下拉关闭效果动画
*/
- (void)pullHideAnimationWithDuration:(CFTimeInterval)duration finishBlk:(void(^)(UIView * view))finishBlk {
__weaktypeof(self) weakSelf =self;
[self.layerpullHideAnimationWithDuration:durationfinishBlk:^(CALayer*layer) {
__strong typeof(self) strongSelf = weakSelf;
!finishBlk?:finishBlk(strongSelf);
}];
}
/**
模仿系统弹框展示动画 默认动画时间0.25s
*/
- (void)systemAlertShowAnimation {
[self.layersystemAlertShowAnimationWithDuration:kAnimationDuration];
}
/**
模仿系统弹框展示动画
*/
- (void)systemAlertShowAnimationWithDuration:(CFTimeInterval)duration {
[self.layersystemAlertShowAnimationWithDuration:duration];
}
/**
模仿系统弹框关闭动画 默认动画时间0.25s
*/
- (void)systemAlertHideAnimationWithFinishBlk:(void(^)(UIView * view))finishBlk {
__weaktypeof(self) weakSelf =self;
[self.layersystemAlertHideAnimationWithDuration:kAnimationDurationfinishBlk:^(CALayer*layer) {
__strong typeof(self) strongSelf = weakSelf;
!finishBlk?:finishBlk(strongSelf);
}];
}
/**
模仿系统弹框关闭动画
*/
- (void)systemAlertHideAnimationWithDuration:(CFTimeInterval)duration finishBlk:(void(^)(UIView * view))finishBlk {
__weaktypeof(self) weakSelf =self;
[self.layersystemAlertHideAnimationWithDuration:durationfinishBlk:^(CALayer*layer) {
__strong typeof(self) strongSelf = weakSelf;
!finishBlk?:finishBlk(strongSelf);
}];
}
@end
// /// ///
@implementation CALayer (animation)
/**
下拉展示效果动画 默认动画时间0.25s
*/
- (void)pullShowAnimation {
[selfpullShowAnimationWithDuration:kAnimationDuration];
}
/**
下拉展示效果动画
*/
- (void)pullShowAnimationWithDuration:(CFTimeInterval)duration {
CGFloaty =self.frame.origin.y;
self.originalAnchorPoint=self.anchorPoint;
self.originalPosition=self.position;
self.anchorPoint=CGPointMake(0.5,0);
self.position=CGPointMake(self.position.x, y);
CABasicAnimation* animation = [CABasicAnimationanimationWithKeyPath:@"transform.scale.y"];
animation.delegate = self;
animation.duration = duration ?: kAnimationDuration;
animation.fromValue = @0;
animation.toValue = @1;
[selfaddAnimation:animationforKey:@"pullShowAnimation"];
}
/**
上拉关闭动画效果 默认动画时间0.25s
*/
- (void)pushHideAnimationWithFinishBlk:(void(^)(CALayer * layer))finishBlk {
[selfpushHideAnimationWithDuration:kAnimationDurationfinishBlk:finishBlk];
}
/**
上拉关闭动画效果
*/
- (void)pushHideAnimationWithDuration:(CFTimeInterval)duration finishBlk:(void(^)(CALayer * layer))finishBlk {
self.finishBlk = finishBlk;
CGFloaty =self.frame.origin.y;
self.originalAnchorPoint=self.anchorPoint;
self.originalPosition=self.position;
self.anchorPoint=CGPointMake(0.5,0);
self.position=CGPointMake(self.position.x, y);
CABasicAnimation* animation = [CABasicAnimationanimationWithKeyPath:@"transform.scale.y"];
animation.delegate = self;
animation.duration = duration ?: kAnimationDuration;
animation.fromValue = @1;
animation.toValue = @0;
[selfaddAnimation:animationforKey:@"pushHideAnimation"];
}
/**
上拉展示动画效果 默认动画时间0.25s
*/
- (void)pushShowAnimation {
[selfpushShowAnimationWithDuration:kAnimationDuration];
}
/**
上拉展示动画效果
*/
- (void)pushShowAnimationWithDuration:(CFTimeInterval)duration {
CGFloaty =self.frame.origin.y+self.bounds.size.height;
self.originalAnchorPoint=self.anchorPoint;
self.originalPosition=self.position;
self.anchorPoint=CGPointMake(0.5,1);
self.position=CGPointMake(self.position.x, y);
CABasicAnimation* animation = [CABasicAnimationanimationWithKeyPath:@"transform.scale.y"];
animation.delegate = self;
animation.duration = duration ?: kAnimationDuration;
animation.fromValue = @0;
animation.toValue = @1;
[selfaddAnimation:animationforKey:@"pushShowAnimation"];
}
/**
下拉关闭效果动画 默认动画时间0.25s
*/
- (void)pullHideAnimationWithFinishBlk:(void(^)(CALayer * layer))finishBlk {
[selfpullHideAnimationWithDuration:kAnimationDurationfinishBlk:finishBlk];
}
/**
下拉关闭效果动画
*/
- (void)pullHideAnimationWithDuration:(CFTimeInterval)duration finishBlk:(void(^)(CALayer * layer))finishBlk {
self.finishBlk = finishBlk;
CGFloaty =self.frame.origin.y+self.bounds.size.height;
self.originalAnchorPoint=self.anchorPoint;
self.originalPosition=self.position;
self.anchorPoint=CGPointMake(0.5,1);
self.position=CGPointMake(self.position.x, y);
CABasicAnimation* animation = [CABasicAnimationanimationWithKeyPath:@"transform.scale.y"];
animation.delegate = self;
animation.duration = duration ?: kAnimationDuration;
animation.fromValue = @1;
animation.toValue = @0;
[selfaddAnimation:animationforKey:@"pullHideAnimation"];
}
/**
模仿系统弹框展示动画 默认动画时间0.25s
*/
- (void)systemAlertShowAnimation {
[selfsystemAlertShowAnimationWithDuration:kAnimationDuration];
}
/**
模仿系统弹框展示动画
*/
- (void)systemAlertShowAnimationWithDuration:(CFTimeInterval)duration {
CAKeyframeAnimation* animation = [CAKeyframeAnimationanimationWithKeyPath:@"transform"];
animation.duration = duration;
animation.values=@[[NSValuevalueWithCATransform3D:CATransform3DMakeScale(0.01f,0.01f,1.0f)],
[NSValuevalueWithCATransform3D:CATransform3DMakeScale(1.1f,1.1f,1.0f)],
[NSValuevalueWithCATransform3D:CATransform3DMakeScale(0.9f,0.9f,1.0f)],
[NSValuevalueWithCATransform3D:CATransform3DIdentity]];
animation.keyTimes=@[@0.0f,@0.5f,@0.75f,@1.0f];
animation.timingFunctions=@[[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[selfaddAnimation:animationforKey:@"ystemAlertShowAnimation"];
}
/**
模仿系统弹框关闭动画 默认动画时间0.25s
*/
- (void)systemAlertHideAnimationWithFinishBlk:(void(^)(CALayer * layer))finishBlk {
[selfsystemAlertHideAnimationWithDuration:kAnimationDurationfinishBlk:finishBlk];
}
/**
模仿系统弹框关闭动画
*/
- (void)systemAlertHideAnimationWithDuration:(CFTimeInterval)duration finishBlk:(void(^)(CALayer * layer))finishBlk {
self.finishBlk = finishBlk;
self.anchorPoint=self.anchorPoint;
self.position=self.position;
CAKeyframeAnimation* animation = [CAKeyframeAnimationanimationWithKeyPath:@"transform"];
animation.duration = duration;
animation.values = @[
[NSValuevalueWithCATransform3D:CATransform3DMakeScale(1.1f,1.1f,1.0f)],
[NSValuevalueWithCATransform3D:CATransform3DMakeScale(1.0f,1.0f,1.0f)],
[NSValuevalueWithCATransform3D:CATransform3DMakeScale(0.9f,0.9f,1.0f)],
[NSValuevalueWithCATransform3D:CATransform3DMakeScale(0.01f,0.01f,1.0f)]
];
animation.keyTimes=@[@0.0f,@0.5f,@0.75f,@1.0f];
animation.timingFunctions=@[[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
animation.delegate = self;
[selfaddAnimation:animationforKey:@"systemAlertHideAnimation"];
}
//MARK:、、、、、、、、、、、、、、、、、、animationDelegate、、、、、、、、、、、、、、、
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {
self.anchorPoint=self.originalAnchorPoint;
self.position=self.originalPosition;
!self.finishBlk?:self.finishBlk(self);
}
//内部使用/
- (void)setOriginalAnchorPoint:(CGPoint)originalAnchorPoint {
objc_setAssociatedObject(self,@selector(originalAnchorPoint), [NSValuevalueWithCGPoint:originalAnchorPoint],OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (CGPoint)originalAnchorPoint {
return[objc_getAssociatedObject(self,@selector(originalAnchorPoint))CGPointValue];
}
- (void)setOriginalPosition:(CGPoint)originalPosition {
objc_setAssociatedObject(self,@selector(originalPosition), [NSValuevalueWithCGPoint:originalPosition],OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (CGPoint)originalPosition {
return[objc_getAssociatedObject(self,@selector(originalPosition))CGPointValue];
}
- (void)setFinishBlk:(void (^)(CALayer *))finishBlk {
objc_setAssociatedObject(self,@selector(finishBlk), finishBlk,OBJC_ASSOCIATION_COPY_NONATOMIC);
}
- (void (^)(CALayer *))finishBlk {
returnobjc_getAssociatedObject(self,@selector(finishBlk));
}
@end