1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| @property (weak, nonatomic) IBOutlet UIView *redView;
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { CABasicAnimation *rotation=[CABasicAnimation animation]; rotation.keyPath=@"transform.rotation"; rotation.toValue=@M_PI_2; CABasicAnimation *position=[CABasicAnimation animation]; position.keyPath=@"position"; position.toValue=[NSValue valueWithCGPoint:CGPointMake(100, 250)]; CABasicAnimation *scale=[CABasicAnimation animation]; scale.keyPath=@"transform.scale"; scale.toValue=@0.2; CAAnimationGroup *group=[CAAnimationGroup animation]; group.animations=@[rotation,position,scale]; group.duration=2; //取消反弹 group.removedOnCompletion=NO; group.fillMode=kCAFillModeForwards; [_redView.layer addAnimation:group forKey:nil]; }
|