Use the increased navigation-bar title in iOS 11

前端 未结 6 726
再見小時候
再見小時候 2021-01-30 02:24

iOS 11 Beta 1 uses the increased navigation-bar title for almost all system-apps (it started doing this in iOS 10 and the Music app). I am wondering if Apple has a public API fo

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-30 02:45

    The only change done to UINavigationBar API for iOS 11 is prefersLargeTitles.

    Documentation here: https://developer.apple.com/documentation/uikit/uinavigationbar/

    You can do it to your own apps with one small change: check "Prefers Large Titles" for your navigation bar in IB, or if you prefer to do it in code using:

    navigationController?.navigationBar.prefersLargeTitles = true
    

    If you need to change the text attributes of the large title you need to use the new largeTitleTextAttributes property on UINavigationBar:

    UINavigationBar.appearance().largeTitleTextAttributes = [
        NSAttributedString.Key.foregroundColor: UIColor.black
    ]
    

提交回复
热议问题