iOS 5: Can you override UIAppearance customisations in specific classes?

醉酒当歌 提交于 2019-12-03 10:30:53
hypercrypt

The way you are doing it is supposed to work, but it doesn't. This does work though:

Swift 4

UINavigationBar.appearance(whenContainedInInstancesOf: [YourOtherVC.self]).tintColor = .black

Objective-C

[[UINavigationBar appearanceWhenContainedIn:[YourOtherVC class], nil] setTintColor:[UIColor blackColor]];

Move your changes to viewWillAppear: instead of viewDidLoad: and it should work.

For that you would do:

id specialNavBarAppearance = [UINavigationBar appearanceWhenContainedIn:[SpecialViewController class], nil];

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