gpt4 book ai didi

ios - 如何实现方法: - (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag

转载 作者:行者123 更新时间:2023-11-29 10:53:54 25 4
gpt4 key购买 nike

我有两个代码块(也在 another topic 中描述)

- (void)AnimateImage:(NSString*)direction{
self.CurrentAnimal.image = [images objectAtIndex:image_nr];
CATransition *animation = [CATransition animation];
[animation setDuration:1.0];
[animation setType:kCATransitionPush];
if([direction isEqualToString:@"left"]){
[animation setSubtype:kCATransitionFromLeft];
}
else {
[animation setSubtype:kCATransitionFromRight];
}
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
[[self.CurrentAnimal layer] addAnimation:animation forKey:nil];
}

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{
//do what you need to do when animation ends...
}

我知道我需要“设置委托(delegate)属性并实现方法”来捕获 animationDidStop 事件,但我无法让它工作。

问题 - 如何设置 .h 和 .m 文件,以便在 CATransition 动画停止时使用此方法执行代码?

最佳答案

设置委托(delegate):

CATransition *animation = [CATransition animation];
....
[animation setDelegate:self];
[animation setDuration:1.0];
[animation setType:kCATransitionPush];

关于ios - 如何实现方法: - (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19280534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com