首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >向右滑动可取消边缘大小

向右滑动可取消边缘大小
EN

Stack Overflow用户
提问于 2019-12-26 08:16:10
回答 2查看 230关注 0票数 0

是否有可能增加UINavigationController对用户触摸做出反应的边缘大小interactivePopGestureRecognizer

也就是说,是否可以从屏幕中间向右滑动来移动和弹出当前的顶部视图控制器,方式与从屏幕左侧边缘相同?

EN

回答 2

Stack Overflow用户

发布于 2019-12-26 13:21:11

代码语言:javascript
运行
复制
    override func viewDidLoad() {
        super.viewDidLoad()
        let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(respondToSwipeGesture))
        swipeRight.direction = .right
        self.view.addGestureRecognizer(swipeRight)

        let swipeLeft = UISwipeGestureRecognizer(target: self, action: #selector(respondToSwipeGesture))
        swipeLeft.direction = .left
        self.view.addGestureRecognizer(swipeLeft)

    }

    // you can track all direction swipe like below, and to do that first you have to add gesture in the view you want to track.
    @objc func respondToSwipeGesture(gesture: UIGestureRecognizer) {
        if let swipeGesture = gesture as? UISwipeGestureRecognizer {
            switch swipeGesture.direction {
            case .right:
                // push pop here
                print("Swiped right")
            case .down:
                print("Swiped down")
            case .left:
                // push pop here
                print("Swiped left")
            case .up:
                print("Swiped up")
            default:
                break
            }
        }
    }
票数 1
EN

Stack Overflow用户

发布于 2019-12-27 06:37:45

最后,使用这个库找到了一个增加边缘触摸大小的解决方案:SwipeTransition

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59482739

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档