1.UITapGestureRecognizer 点击/双击手势
var tapGesture = UITapGestureRecognizer(target: self, action: "handleTapGesture:") //设置手势点击数,双击:点2下 tapGesture.numberOfTapsRequired = 2 self.view.addGestureRecognizer(tapGesture)
2.UIPinchGestureRecognizer 捏 (放大/缩小)手势
var pinchGesture = UIPinchGestureRecognizer(target: self, action: "handlePinchGesture:") self.view.addGestureRecognizer(pinchGesture)
3.UIRotationGestureRecognizer 旋转手势
var rotateGesture = UIRotationGestureRecognizer(target: self, action: "handleRotateGesture:") self.view.addGestureRecognizer(rotateGesture)
4. UIPanGestureRecognizer 拖动手势
var panGesture = UIPanGestureRecognizer(target: self, action: "handlePanGesture:") self.view.addGestureRecognizer(panGesture)
5. UISwipeGestureRecognizer 划动手势
var swipeGesture = UISwipeGestureRecognizer(target: self, action: "handleSwipeGesture:") swipeGesture.direction = UISwipeGestureRecognizerDirection.Left //不设置是右 self.view.addGestureRecognizer(swipeGesture)
6. UILongPressGestureRecognizer 长按手势
var longpressGesutre = UILongPressGestureRecognizer(target: self, action: "handleLongpressGesture:") //长按时间 // longpressGesutre.minimumPressDuration //所需触摸次数 /// longpressGesutre.numberOfTouchesRequired self.view.addGestureRecognizer(longpressGesutre) UIGestureRecognizerState 枚举定义如下 enum UIGestureRecognizerState : Int { case Possible // the recognizer has not yet recognized its gesture, but may be evaluating touch events. this is the default state case Began // the recognizer has received touches recognized as the gesture. the action method will be called at the next turn of the run loop case Changed // the recognizer has received touches recognized as a change to the gesture. the action method will be called at the next turn of the run loop case Ended // the recognizer has received touches recognized as the end of the gesture. the action method will be called at the next turn of the run loop and the recognizer will be reset to UIGestureRecognizerStatePossible case Cancelled // the recognizer has received touches resulting in the cancellation of the gesture. the action method will be called at the next turn of the run loop. the recognizer will be reset to UIGestureRecognizerStatePossible case Failed // the recognizer has received a touch sequence that can not be recognized as the gesture. the action method will not be called and the recognizer will be reset to UIGestureRecognizerStatePossible }
© 版权声明
本文刊载的所有内容,包括文字、图片、音频、视频、软件、程序、以及网页版式设计等部门来源于互联网,版权均归原作者所有!本网站提供的内容服务于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯本网站及相关权利人的合法权利。
联系信息:邮箱aoxolcom@163.com或见网站底部。
联系信息:邮箱aoxolcom@163.com或见网站底部。
THE END
请登录后发表评论
注册
社交帐号登录