用POP动画引擎实现弹簧动画(POPSpringAnimation)

效果图:

用POP动画引擎实现弹簧动画(POPSpringAnimation)

#import "ViewController.h"
#import <POP.h> @interface ViewController () @property (nonatomic, weak) UIView *testView; @end @implementation ViewController - (void)viewDidLoad
{
[super viewDidLoad]; self.view.backgroundColor = [UIColor blackColor]; // 初始化测试控件
UIView *testView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
testView.center = self.view.center;
testView.backgroundColor = [UIColor redColor];
self.testView = testView;
[self.view addSubview:testView];
} - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
// 初始化弹簧动画
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerBounds];
springAnimation.springSpeed = ; // 设置动画速度(常用)
springAnimation.springBounciness = ; // 设置弹性大小(常用)
// springAnimation.dynamicsFriction = 10; // 设置阻止弹性的阻力(选用)
// springAnimation.dynamicsTension = 100; // 设置弹性的张力(可以理解为每次变大的程度, 选用)
if (self.testView.frame.size.width == ) {
springAnimation.toValue = [NSValue valueWithCGRect:CGRectMake(, , , )];
} else {
springAnimation.toValue = [NSValue valueWithCGRect:CGRectMake(, , , )];
} // 添加动画
[self.testView.layer pop_addAnimation:springAnimation forKey:nil];
} @end

github:https://github.com/RinpeChen/POPSpringAnimationDemo

上一篇:height:100%不起作用(无效),div全屏


下一篇:redis参考文档