rotating a view on touch

≯℡__Kan透↙ 提交于 2019-12-30 04:38:06

问题


I have to rotate a view circularly on finger touch...I mean like dialing the old phones number...and the touch should be only on corners.....can any one help me...i have tried it a lot...but was not successes


回答1:


You need to define the UIRotationGestureRecognize on the view that you want to rotate and than add a selector method and implement it like this.

Add this to you viewDidLoad method

UIRotationGestureRecognizer *rotate = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotation:)];

[myUIViewObject addGestureRecognizer:rotate];

[rotate release];

And then implement the method.

- (void) rotation:(UIRotationGestureRecognize *) sender
{
    CGAffineTransform myTransform = CGAffineTransformMakeRotation(sender.rotation);
    sender.view.transform = myTransform;
}

PS. myUIViewObject can be any UIView Object that you want to rotate.

Edit:

you will find a lot of information on this here:

http://www.iphonedevsdk.com/forum/iphone-sdk-development/49847-how-find-angle-two-points.html



来源:https://stackoverflow.com/questions/5189626/rotating-a-view-on-touch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!