iphone-轻松按下按钮->;删除效果?或移动->;重新定位视图效果?
在iphone的主页上,你可以按住一个应用程序2秒钟,然后每个人都在颤抖,等待被删除或重新定位 我怎么能以自己的观点看待这一点iphone-轻松按下按钮->;删除效果?或移动->;重新定位视图效果?,iphone,uiview,shake,Iphone,Uiview,Shake,在iphone的主页上,你可以按住一个应用程序2秒钟,然后每个人都在颤抖,等待被删除或重新定位 我怎么能以自己的观点看待这一点 按住某个位置,每个子视图都在抖动 按住某个位置,以便用户可以重新定位视图 就像iOs的主屏幕、ibook或其他许多应用程序一样 谢谢1)您必须使用UILongPressGestureRecognitor来检测长时间按压 UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRec
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(startWobbling)];
[anyView addGestureRecognizer:longPressGesture];
[longPressGesture release];
然后在startwobling选择器中执行以下操作:
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的示例代码:您可以使用Three20库中的TTLauncher视图。它很容易定制,并为您提供了所需的所有抖动和重新定位功能:谢谢,Vin,所以您的意思是没有直接的SpringBoard工具可供我使用?我认为没有专用API,SpringBoard是无法直接使用的。请注意noob iOS开发人员(像我一样!)。本例假设选择器方法签名没有参数。如果使用选择器签名,例如:
-(void)startwobling:(uilongpressurerecognizer*)recognizer{}
,则需要修改选择器声明以包含冒号。将此:@selector(startwobling)
更改为:@selector(startwobling:)