iphone - 按下按钮的简单方法 ->删除效果?或移动->重新定位视图效果?

发布于 2024-10-06 21:36:08 字数 220 浏览 2 评论 0原文

在iPhone的Home上,你可以按住一个应用程序2秒,然后每个应用程序都在摇晃并等待被删除或重新定位。

我怎么能有这样的想法呢?

  1. 按&按住某处,每个子视图都在摇晃

  2. 按&按住某处以便用户可以重新定位视图?

就像 iO 的主屏幕或 ibook 或许多其他应用程序一样?

谢谢

On iphone's home, you can press and hold on one app for 2 secs, then everyone is shaking and waiting to be delete or relocate.

How can I have this in my own view?

  1. press & hold on somewhere and every subview is shaking

  2. press & hold on somewhere so user can relocate the views?

Just like iOs's home screen or ibook or quite many other apps?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

叶落知秋 2024-10-13 21:36:08

1) 您必须使用 UILongPressGestureRecognizer 来检测长按

    UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(startWobbling)];
[anyView addGestureRecognizer:longPressGesture];
[longPressGesture release];

,然后在 startWobbling 选择器中执行以下操作:

CGAffineTransform leftWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-5.0));
CGAffineTransform rightWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(5.0));


view.transform = leftWobble;  // starting point

[UIView beginAnimations:@"wobble" context:view];
[UIView setAnimationRepeatAutoreverses:YES]; // important
[UIView setAnimationRepeatCount:10];
[UIView setAnimationDuration:0.25];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(wobbleEnded:finished:context:)];

btn.transform = rightWobble; // end here & auto-reverse

[UIView commitAnimations];

2) 请参阅 Apple 的 Touches 示例代码: http://developer.apple.com/library/ios/#samplecode/Touches/Introduction/Intro.html

1) You'd have to use UILongPressGestureRecognizer to detect long presses

    UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(startWobbling)];
[anyView addGestureRecognizer:longPressGesture];
[longPressGesture release];

and then in the startWobbling selector do:

CGAffineTransform leftWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-5.0));
CGAffineTransform rightWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(5.0));


view.transform = leftWobble;  // starting point

[UIView beginAnimations:@"wobble" context:view];
[UIView setAnimationRepeatAutoreverses:YES]; // important
[UIView setAnimationRepeatCount:10];
[UIView setAnimationDuration:0.25];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(wobbleEnded:finished:context:)];

btn.transform = rightWobble; // end here & auto-reverse

[UIView commitAnimations];

2) Refer Touches sample code from Apple: http://developer.apple.com/library/ios/#samplecode/Touches/Introduction/Intro.html

盛夏已如深秋| 2024-10-13 21:36:08

您可以使用 Three20 库中的 TTLauncher 视图。它非常容易定制,并为您提供所需的所有摆动和重新定位:http://third20.info/展示/启动器

You can use the TTLauncher view from the Three20 lib. It is pretty easy to customize and gives you all the wobbling and relocating you are looking for: http://three20.info/showcase/launcher

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文