CAKeyframeAnimation beginTime

时间:2015-07-13 02:41:07

标签: ios iphone caanimation

我正在编写一个简单的项目来学习CAKeyframeAnimation。我有一个小的UIView矩形,item1,我正在屏幕上移动。

@interface ViewController ()
@property (nonatomic, strong) UIView *item1;
@end
@implementation ViewController

- (IBAction)StartButton:(id)sender
{
CAKeyframeAnimation *animateItem1 = [CAKeyframeAnimation animation];
animateItem1.keyPath = @"position.x";
animateItem1.values = @[@0, @15, @113, @123, @135];
animateItem1.keyTimes = @[@0, @.50, @.80, @.90, @1.0];
animateItem1.duration = 4.;
// animateItem1.beginTime = 2.0;
animateItem1.additive = YES;
animateItem1.fillMode = kCAFillModeForwards;
animateItem1.removedOnCompletion = NO;
[self.item1.layer addAnimation:animateItem1 forKey:@"move rect1"];
}

-(void)viewWillAppear:(BOOL)animated
{
self.item1 = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 10, 10)];
self.item1.backgroundColor = [UIColor redColor];
[self.view addSubview:self.item1];
}

这就像我期望的那样运行。但是,如果我取消注释beginTime属性。动画只是跳到最后而不执行每一帧。在阅读了这个解释页面http://ronnqvi.st/controlling-animation-timing/之后,我只是期待动画开始并在开始动画后2.0秒开始。你能告诉我我做错了什么吗?谢谢。

0 个答案:

没有答案