Modern User Interaction on iOS

System Gesture Interaction

  1. tap, pinch, rotate, long press 與 system gesture recognizer同時進(jìn)行
  2. pan, swipe 在 system gesture recognizer 之后進(jìn)行
  3. System gesture or app gesture? Use New API.
class MyViewController: UIViewController {
    // override to return which screen edges to defer system gestures
    override func preferredScreenEdgesDeferringSystemGestures() -> UIRectEdge {
        return deferControlCenter ? .bottom : UIRectEdge()
    }
    // call whenever your method would return a different screen edge
    var deferControlCenter : Bool {
        didSet { setNeedsUpdateOfScreenEdgesDeferringSystemGestures() }
    }
}

For Containers Only:

class MyContainerViewController: UIViewController {
    // override to return which child view controller to consult
    override func childViewControllerForScreenEdgesDeferringSystemGestures() -> UIViewController? {
        return mySelectedChildViewController
    }
}

Playing Nice With Drag and Drop

  1. 添加 drag interaction 到 view 的interaction array,drag interaction 創(chuàng)建一些 gesture recognizers 添加到view上,并將自己設(shè)置為gesture recognizers 的delegate.
  2. 在View上添加long press,long press 被 delay,按的時間稍長才會開始,移動是被drag interactgion cancelled.


    f15097f5-56ba-440a-a6cf-d1a7a6bb6d5f.png
  3. Adding to a Drag
func dragInteraction(_ interaction: UIDragInteraction, itemsForAddingTo session: UIDragSession, withTouchAt point: CGPoint) -> [UIDragItem] {
    // Returning 0 items allows normal touch processing to continue
    return []
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容