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

后端 未结 3 2184
梦谈多话
梦谈多话 2021-02-13 05:52

I\'m building an app with many view controllers: I have a UITabBarController which holds 4 UINavigationController. I want all the nav bars to be my cus

相关标签:
3条回答
  • 2021-02-13 06:42

    For that you would do:

    id specialNavBarAppearance = [UINavigationBar appearanceWhenContainedIn:[SpecialViewController class], nil];
    
    [specialNavBarAppearance setBarStyle:UIBarStyleBlack];
    [specialNavBarAppearance setTranslucent:YES];
    
    0 讨论(0)
  • 2021-02-13 06:52

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

    0 讨论(0)
  • 2021-02-13 06:53

    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]];
    
    0 讨论(0)
提交回复
热议问题