3

在iphone之家,你可以按住一个应用程序2秒,然后每个人都在颤抖等待被删除或重新定位。

我怎么能有这个在我自己的看法?

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

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

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

谢谢

4

2 回答 2

6

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

于 2010-12-07T11:19:48.360 回答
2

您可以使用 Three20 库中的 TTLauncher 视图。它很容易定制,并为您提供您正在寻找的所有摇摆和重新定位:http: //three20.info/showcase/launcher

于 2010-12-07T12:11:41.243 回答