Navigation Bar title font problem on ios 13

大城市里の小女人 提交于 2020-04-18 04:04:29

问题


I’m using Xcode 11.4 and iOS 13.4. I have set navigation bar title custom font using UINavigatinBar.appearance() And it works correctly but on iOS 13+ when i try to push to another VC and then comeback to the parent VC, the parent VC title font suddenly has been set to default font and after a second it changes back to the custom font.

Below is a gif of the problem:

nav bar font problem


回答1:


Here you go, manage it in viewDidAppear:

let lblTitle = UILabel()

let titleAttribute: [NSAttributedString.Key: Any] = [.font: UIFont.boldSystemFont(ofSize: 21),
                                                .foregroundColor: UIColor.black]

let attributeString = NSMutableAttributedString(string: "Navigation Title", attributes: titleAttribute)

lblTitle.attributedText = attributeString

lblTitle.sizeToFit()
navigationItem.titleView = lblTitle


来源:https://stackoverflow.com/questions/60902418/navigation-bar-title-font-problem-on-ios-13

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!