LoginSignup
21
21

More than 5 years have passed since last update.

【iOS】ナビゲーションバーのタイトルのフォントとサイズをコードで変更する【Swift3.0】

Last updated at Posted at 2017-03-10

    // フォント種をTime New Roman、サイズを10に指定
    self.navigationController?.navigationBar.titleTextAttributes
            = [NSFontAttributeName: UIFont(name: "Times New Roman", size: 15)!]

テストコード

ViewController.swift


import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        // タイトルをセット
        self.navigationItem.title = "title font test"

        // フォント種をTime New Roman、サイズを10に指定
        self.navigationController?.navigationBar.titleTextAttributes
            = [NSFontAttributeName: UIFont(name: "Times New Roman", size: 15)!]

    }

}

実行結果
Glass_と_iPhone_6s_–_iOS_10_0__14A345_.png

21
21
1

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
21
21