1
Help us understand the problem. What are the problem?

posted at

Organization

【Swift5】NavigationBarのBackボタンを画像にする

NavigationBarの< Backボタンを画像にする

これを
スクリーンショット 2022-08-03 23.08.55.png
これにする
スクリーンショット 2022-08-03 23.12.38.png

コード

ViewController.swift
    private func setNaviBackButton() {
        let backImage = UIImage(named: "backIcon")?.withRenderingMode(.alwaysOriginal)
        navigationItem.leftBarButtonItem = UIBarButtonItem.init(image: backImage, style: .plain, target: self, action: #selector(tappedBackButton))
    }

    @objc func tappedBackButton() {
        self.navigationController?.popViewController(animated: true)
    }

Register as a new user and use Qiita more conveniently

  1. You can follow users and tags
  2. you can stock useful information
  3. You can make editorial suggestions for articles
What you can do with signing up
1
Help us understand the problem. What are the problem?