问题
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