Wrong large title animation with custom back button font

508 Views Asked by At

I just changed the font of the back button while using large titles in the navigation bar. This worked fine, but then I had the problem that the transition/animation of the small back button text to the large title of the previous page looked pretty weird. The large title appeared a second time with a kind of fade-in effect at the top left corner of the view controller. So how can I prevent this strange behavior?

1

There are 1 best solutions below

2
On BEST ANSWER

I could solve this problem on my own, but since I could not find a similar topic/problem/solution on the web I wanted to share the solution, just in case someone else has the same problem one day.

To solve this strange behavior I had to set the custom font for the normal UIControlState and additionally for the highlighted one.

UIBarButtonItem.appearance().setTitleTextAttributes([kCTFontAttributeName as NSAttributedStringKey: UIFont(name: "Futura", size: 17)!], for: .normal)

UIBarButtonItem.appearance().setTitleTextAttributes([kCTFontAttributeName as NSAttributedStringKey: UIFont(name: "Futura", size: 17)!], for: .highlighted)

Hope this helps! :)