首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIImageView stopAnimation

UIImageView stopAnimation
EN

Stack Overflow用户
提问于 2013-04-04 15:13:18
回答 1查看 1.2K关注 0票数 4

在Xcode中,我有两个按钮:、Start、Stop

当您单击Start startClick时,当您单击停止时,调用 stopClick

当您单击Start时,UIImageView映像将显示与NSArray不同的图像。当您单击 stop 时,它会停止,但我希望它在我单击Stop时显示的图像上停止。就在此刻,它停了下来.有什么帮助吗?

下面是代码的一部分:

代码语言:javascript
复制
-  (IBAction)startClick:(id)sender {

    color.animationImages = [NSArray arrayWithObjects:
                            [UIImage imageNamed: @"img1.png"],
                            [UIImage imageNamed: @"img2.png"],
                            [UIImage imageNamed: @"img3.png"],
                            [UIImage imageNamed:  @"img4.png"],nil];     

    [color setAnimationRepeatCount: 0];
    color.animationDuration = 1;
    [color startAnimating];
}

- (IBAction)stopClick:(id)sender {
    [color stopAnimating];

    //What code do i put here to display the last image? (as i clicked stop).

}

我还想添加if状态,因为如果显示的颜色是img1.png,那么就这样做.如果它这么做了..。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-04 15:18:49

此代码将暂停动画:

代码语言:javascript
复制
color.frame = [[color.layer presentationLayer] frame];
[color.layer removeAllAnimations];
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15815135

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档