11
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

画面上のどこからでもスワイプバックできるようにする

Last updated at Posted at 2018-11-15

iOS標準で付いている、画面左端からのスワイプで前画面に戻る機能を画面上のどこをスワイプしても戻れるようにする方法

ViewController.swift
override func viewDidLoad() {
    super.viewDidLoad()
    // ↓この3行を追加
    let target = self.navigationController?.value(forKey: "_cachedInteractionController")
    let recognizer = UIPanGestureRecognizer(target: target, action: Selector(("handleNavigationTransition:")))
    self.view.addGestureRecognizer(recognizer)
}

この3行をviewDidLoadとかで呼ぶだけ。
お手軽です。

11
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?