美文网首页
IOS触屏事件和触摸手势

IOS触屏事件和触摸手势

作者: 79d12e22ec53 | 来源:发表于2019-04-28 19:05 被阅读0次

    触屏事件和触摸手势

    UIRsponder

    
    
    import UIKit
    
    class ViewController: UIViewController{
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
        }
    
        override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
            let touch = touches.first
            let touchPoint = touch?.location(in: self.view)
            
        }
        
        override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
            <#code#>
        }
        
        override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
            <#code#>
        }
        
        override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
            <#code#>
        }
    
    }
    
    
    
    
    

    UItouch 常用属性

    view 触摸事件所在视图
    timestamp 触摸事件发生时间戳
    tapcountlocation 触摸事件点击次数
    previousLocation 触摸事件在指定视图中上一次移动时候的位置
    phase 触摸事件所在阶段
    forse 触摸压力值,1.0表示普通
    let view
    view.isUserInteractionEnabled = true
    let gesture = UITapGestureRecognizer
    /*
    UILongPressGestureRecognizer
    UIPinchGestureRecognizer
    */
    guesture.numberOfTapsRequired = 2 // 点击次数
    guesture.numberOfTouchesRequired = 1 // 第几手指数量
    

    相关文章

      网友评论

          本文标题:IOS触屏事件和触摸手势

          本文链接:https://www.haomeiwen.com/subject/tjhngqtx.html