iOS 6 appearance when contained in multiple classes

后端 未结 1 1671
小蘑菇
小蘑菇 2021-02-04 04:18

I’m using the appearanceWhenContainedIn method on certain UI elements that I want to customise in my iOS 6 app. The problem I found is that none of my customisation

相关标签:
1条回答
  • 2021-02-04 05:01

    From the docs:

    appearanceWhenContainedIn:

    ...

    The appearance proxy for the receiver in a given containment hierarchy.

    That actually means that nil-terminated list defines not the list of the container classes for UIBarButtonItem, but container hierarchy from top to bottom, so

    [UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], [UIToolbar class], nil]
    

    returns appearance proxy for UIBarButtonItem that is inside UINavigationBar, and UINavigationBar in turn is inside UIToolbar.

    or

    [[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class],[ViewController class], nil] setTintColor:[UIColor redColor]];
    

    set red tint color for UIBarButtonItems that are in any UIToolBar which are in ViewController class.

    So to set appearance for UINavigationBar and UIToolBar separately you'll need 2 separate calls to the +appearanceWhenContainedIn: method

    0 讨论(0)
提交回复
热议问题