iPhone - Making a Tab Bar Transparent

孤街浪徒 提交于 2019-12-18 13:37:57

问题


How do I make a tab bar transparent in cocoa touch?


回答1:


Since UITabBar is a subclass of UIView, have you tried adjusting its alpha property?

Note that if you are trying to modify a tab bar associated with a UITabBarController, you should consider this warning from Apple, located in the reference for UITabBar:

Important: In iOS 3.0 and later, you should not attempt to use the methods and properties of this class to modify the tab bar when it is associated with a tab bar controller object. Modifying the tab bar in this way results in the throwing of an exception. Instead, any modifications to the tab bar or its items should occur through the tab bar controller interface. You may still directly modify a tab bar object that is not associated with a tab bar controller.




回答2:


Now with iOS 5 you can change the UITabBar appearance to make only the background transparent with a simple line of code:

[[UITabBar appearance] setTintColor:[[UIColor alloc] initWithRed:0 green:0 blue:0 alpha:0.2]];


来源:https://stackoverflow.com/questions/3735076/iphone-making-a-tab-bar-transparent

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