iOS 6 appearance when contained in multiple classes

牧云@^-^@ 提交于 2019-12-02 22:38:46

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

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