1.书写动画代码,设置参数。
CAKeyframeAnimation * mover = [CAKeyframeAnimation animationWithKeyPath:@"position"];
NSMutableArray * val = [NSMutableArray array];
[val addObject:[NSValue valueWithCGPoint:CGPointMake(20, 20)]];
[val addObject:[NSValue valueWithCGPoint:CGPointMake(300, 20)]];
[val addObject:[NSValue valueWithCGPoint:CGPointMake(300, 200)]];
[val addObject:[NSValue valueWithCGPoint:CGPointMake(100, 400)]];
[mover setValues:val];
[mover setDuration:2];
2.选择某一视图控件,并加载动画。UIView * temp = [self.view viewWithTag:100];
[temp.layer addAnimation:mover forKey:@"hello"];
3.选择动画开始模式,例如点击按钮、点击屏幕等。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
;转载于
http://itjoy.org/?p=634