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 动画


猜你喜欢
- android 4中的android RadioButton问题 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01