POP-一個點擊帶有放大還原的動畫效果,pop-放大還原動畫
原理
監聽螢幕的點擊事件
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
- (void)touchesCancelled:(nullable NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
動畫
pop動畫,需要pop架構
兩個動畫一個放大,一個還原
kPOPViewScaleXY:放大寬高
代碼
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { POPSpringAnimation *scaleAnimation = [POPSpringAnimation animation]; scaleAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewScaleXY];//寬高改變 scaleAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(1.3, 1.3)];//1.3倍 [self pop_addAnimation:scaleAnimation forKey:@"scaleAnimationKey"];//執行動畫 scaleAnimation.completionBlock = ^(POPAnimation *animation,BOOL finish) { //動畫回調 POPSpringAnimation *scaleAnimation = [POPSpringAnimation animation]; scaleAnimation.springBounciness = 16; // value between 0-20 scaleAnimation.springSpeed = 14; // value between 0-20 scaleAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewScaleXY]; scaleAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(1.0, 1.0)]; [self pop_addAnimation:scaleAnimation forKey:@"scaleAnimationKey"]; };}