在特定的转场之后如何触发我的动画?
How can I trigger my animation after a specific segue?
我有一个正在运行的动画。我遵循了这个答案 Xcode How to move an image up and down animation
我能够通过按钮触发动画。我真正想要的是在特定的 segue 之后触发动画。当我转至情节提要中的特定视图时是否可以触发此动画?
动画在我的 ViewController
实现中的一个方法中。
-(void)animatePicker
{
NSLog(@"Animate");
CGPoint startPoint = (CGPoint){100.f, 100.f};
CGPoint middlePoint = (CGPoint){400.f, 400.f};
CGPoint endPoint = (CGPoint){600.f, 100.f};
CGMutablePathRef thePath = CGPathCreateMutable();
CGPathMoveToPoint(thePath, NULL, startPoint.x, startPoint.y);
CGPathAddLineToPoint(thePath, NULL, middlePoint.x, middlePoint.y);
CGPathAddLineToPoint(thePath, NULL, endPoint.x, endPoint.y);
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.duration = 3.f;
animation.path = thePath;
[pickerCircle.layer addAnimation:animation forKey:@"position"];
pickerCircle.layer.position = endPoint;
}
实现一个-(void)viewDidAppear;在你的 UIViewController 中调用你的动画函数。
当 UIViewController 视图已创建并出现时调用此函数。
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSLog(@"viewDidAppear");
[masterViewController animate];
}
我有一个正在运行的动画。我遵循了这个答案 Xcode How to move an image up and down animation
我能够通过按钮触发动画。我真正想要的是在特定的 segue 之后触发动画。当我转至情节提要中的特定视图时是否可以触发此动画?
动画在我的 ViewController
实现中的一个方法中。
-(void)animatePicker
{
NSLog(@"Animate");
CGPoint startPoint = (CGPoint){100.f, 100.f};
CGPoint middlePoint = (CGPoint){400.f, 400.f};
CGPoint endPoint = (CGPoint){600.f, 100.f};
CGMutablePathRef thePath = CGPathCreateMutable();
CGPathMoveToPoint(thePath, NULL, startPoint.x, startPoint.y);
CGPathAddLineToPoint(thePath, NULL, middlePoint.x, middlePoint.y);
CGPathAddLineToPoint(thePath, NULL, endPoint.x, endPoint.y);
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.duration = 3.f;
animation.path = thePath;
[pickerCircle.layer addAnimation:animation forKey:@"position"];
pickerCircle.layer.position = endPoint;
}
实现一个-(void)viewDidAppear;在你的 UIViewController 中调用你的动画函数。
当 UIViewController 视图已创建并出现时调用此函数。
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSLog(@"viewDidAppear");
[masterViewController animate];
}