ios pull代码不提示成功_iOS 弹框下拉上拉动画一行代码实现

此处是.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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值