美文网首页
Modern User Interaction on iOS

Modern User Interaction on iOS

作者: coderzcj | 来源:发表于2017-08-03 16:48 被阅读67次

    System Gesture Interaction

    1. tap, pinch, rotate, long press 与 system gesture recognizer同时进行
    2. pan, swipe 在 system gesture recognizer 之后进行
    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 创建一些 gesture recognizers 添加到view上,并将自己设置为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 []
    }
    

    相关文章

      网友评论

          本文标题:Modern User Interaction on iOS

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