9
12

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.

Swift 3でUINavigationControllerで遷移したときに戻るボタンのテキスト「Back」を消して矢印だけにする

Posted at

螢幕快照 2017-01-31 19.08.31.png
  • XcodeのSingle Page Applicationで新規作成
  • Storyboardの最初にあるViewController上で[Editor]→[Embed in]→[Navigation Controller]
  • もうひとつViewControllerを追加し、showのセグエで結ぶ
    • SecondViewControllerクラスを作り登録しておく

やりたいこと

Before After
螢幕快照 2017-01-31 19.11.32.png 螢幕快照 2017-01-31 19.12.30.png

Storyboardで作ってるぜな場合

  • 最初のViewControllerのNavigation Barをクリック
  • 右側のインスペクタ群からAttributes Inspectorを選択
  • Navigation ItemのBack Buttonの値を _ (空値とか半角スペース)にする
螢幕快照_2017-01-31_19_31_38.png

コードでやってるぜな場合

  • __NavigationControllerが最初に表示するViewControllerのクラス__の viewDidLoad() 内に次の記述を追加します。
ViewController.swift
navigationController!.navigationBar.topItem!.title = " "

参考

How do I change the title of the “back” button on a Navigation Bar - StackOverFlow

9
12
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
9
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?