rotating a view on touch(旋转触摸视图)
问题描述
我必须在手指触摸时循环旋转视图......我的意思是像拨打旧电话号码......并且触摸应该只在角落......任何人都可以帮助我......我有尝试了很多...但没有成功
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
推荐答案
您需要在要旋转的视图上定义 UIRotationGestureRecognize,然后添加选择器方法并像这样实现它.
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.
给你添加这个viewDidLoad方法
UIRotationGestureRecognizer *rotate = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotation:)];
[myUIViewObject addGestureRecognizer:rotate];
[rotate release];
然后实现方法.
- (void) rotation:(UIRotationGestureRecognize *) sender
{
CGAffineTransform myTransform = CGAffineTransformMakeRotation(sender.rotation);
sender.view.transform = myTransform;
}
PS.myUIViewObject 可以是您想要旋转的任何 UIView 对象.
PS. myUIViewObject can be any UIView Object that you want to rotate.
你会在这里找到很多关于这方面的信息:
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
这篇关于旋转触摸视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:旋转触摸视图
基础教程推荐
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
- Play 商店的设备兼容性问题 2022-01-01
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
- Android Volley - 如何动画图像加载? 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
- UIImage 在开始时不适合 UIScrollView 2022-01-01
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
