如何停止 UIView 动画
我在 UIScrollView
中有几个 UIImageViews
,当用户长按其中一个时,我想摆动它们。与长按 iPad/iPhone 菜单中的图标时的行为非常相似。
所以我有以下内容:
- (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
方法,所以没关系。但是那么...
- 如何从这些 UIImageViews 中删除 UIView 动画?
- 我可以将此操作绑定到用户按下设备上的主页按钮吗?
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.
So I have the following:
- (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");
}
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...
- 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么
或者
then
or