【发布时间】:2026-01-30 11:10:02
【问题描述】:
我有一个 UIImageView 将一系列图片显示为动画。这部分项目运行良好。
我想在动画结束时显示一个标签。 Imageview 动画结束时是否会触发事件?
【问题讨论】:
标签: iphone objective-c animation uiimageview
我有一个 UIImageView 将一系列图片显示为动画。这部分项目运行良好。
我想在动画结束时显示一个标签。 Imageview 动画结束时是否会触发事件?
【问题讨论】:
标签: iphone objective-c animation uiimageview
使用setAnimationDuration:设置动画的持续时间
同时你配置performSelector:withObject:withDelay 的延迟与动画的持续时间相同
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0]; //the animation will last for 1.0s
//some animation code here
[UIView commitAnimations];
[self performSelector:@selector(someMethodToDisplayLabel) withObject:nil afterDelay:1.0];
//someMethodToDisplayLabel will be called after 1.0s
【讨论】:
似乎没有为此举办活动/代表。我的第一个直觉是自己计算动画的长度,然后设置一个 NSTimer,这样当动画结束时,NSTimer 就会触发显示你接下来要显示的任何内容。
【讨论】: