简体   繁体   English

运行时更改UITabBar

[英]Change UITabBar while running

I'm making a theme for my app, and when I switch themes, the UITabBar doesn't want to apply coloration. 我正在为我的应用程序创建主题,当我切换主题时,UITAbBar不想应用颜色。

The bar only take the color defined in the active theme at launching. 该栏仅采用启动时活动主题中定义的颜色。 I'm calling this but it doesn't work :/ 我正在打电话给我,但这不起作用:/

    [[UITabBar appearance] setBarStyle:[theme tabBarStyle]];

Appearance proxy has no effect on existing views - only on future views. 外观代理对现有视图无效-仅对将来的视图有效。 That is why it is usually called only at launch time, before there is any interface at all. 这就是为什么通常只在启动时才调用它,而根本没有任何接口。

You are free to set the appearance proxy at any time, but if you want existing views to change their appearance you must do that in the normal way, ie by sending a message directly to those existing views. 您可以随时设置外观代理,但如果要现有视图更改其外观,则必须以常规方式进行操作,即直接向这些现有视图发送消息。 You'll have organize your code in such a way as to make that possible. 您将以使之成为可能的方式来组织代码。

Alternatively, of course, you can set the appearance proxy, destroy your entire existing interface, and then rebuild your interface under the influence of the new proxy settings. 当然,您也可以设置外观代理,破坏整个现有接口,然后在新代理设置的影响下重建接口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM