How to stop an UIView animation(如何停止 UIView 动画)
本文介绍了如何停止 UIView 动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 UIScrollView
中有几个 UIImageViews
,当用户长按其中一个时,我想摆动它们.与长按 iPad/iPhone 菜单中的图标时的行为非常相似.
I have several UIImageViews
within a UIScrollView
that I want to wiggle when the user long-presses one of them. So similar to the behavior you get when you long-press an icon in your iPad/iPhone menu.
所以我有以下内容:
- (void)startWiggling {
for (UIImageView *touchView in [scrollView subviews]) {
[UIView beginAnimations:@"wiggle" context:nil];
[UIView setAnimationDuration:0.1];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationRepeatCount:FLT_MAX];
//wiggle 1 degree both sides
touchView.transform = CGAffineTransformMakeRotation();
touchView.transform = CGAffineTransformMakeRotation(-0.0174532925);
[UIView commitAnimations];
}
}
- (void)stopWiggling {
NSLog(@"Stop wiggling");
}
这很好用.问题是...如何在用户按下按钮后使其停止摆动?我有一个按钮并连接它等,它到达了 stopWiggling
方法,所以没关系.不过这样……
This works fine. The issue is... How can I make it stop wiggling after the user has pressed a button? I have a button and connected it etc and it's reaching the stopWiggling
method, so that's fine. But so...
- 如何从这些
UIImageViews
中移除 UIView 动画? - 我可以将此操作绑定到在其设备上按下主页按钮的用户吗?
- How do I remove the UIView animation from these
UIImageViews
? - Can I bind this action to the user pressing the home button on their device?
推荐答案
#import <QuartzCore/QuartzCore.h>
然后
[myView.layer removeAllAnimations];
或
[self.view.layer removeAllAnimations];
这篇关于如何停止 UIView 动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
织梦狗教程
本文标题为:如何停止 UIView 动画


基础教程推荐
猜你喜欢
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iOS4 创建后台定时器 2022-01-01