How to set the transparency color for Toolbar and Navigation bar using MonoTouch?

人盡茶涼 提交于 2019-12-11 23:41:03

问题


How to set the transparency color for Toolbar and Navigation bar? I need to show background image on whole screen. But I can't give the transparency color for Toolbar and Navigation bar. I assigned UIColor.Clear. But no use. It is showing black color.


回答1:


Better answer is hide the navigation bar or toolbar..

or

its strange requirement so. u hav to use custo navigationbar and custom buttons :)




回答2:


For UIToolBar & UINavigationBar Use the below property

@property(nonatomic,assign,getter=isTranslucent) BOOL translucent

Go to Apple Documentation

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIToolbar_Class/Reference/Reference.html

http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationBar_Class/Reference/UINavigationBar.html

Here is some finding:

Define a category for UIToolbar for brining transparency:

@implementation UIToolbar(Transparent) 
-(void)drawRect:(CGRect)rect {
    // do nothing in here
}
@end

In the IB set the toolbar as Black Translucent and non opaque.

Note that: this would make all toolbars in your app transparent.

For UINavigationBar:

@implementation UINavigationBar (custom)
- (void)drawRect:(CGRect)rect {}
@end

navgationController.navigationBar.backgroundColor = [UIColor clearColor];


来源:https://stackoverflow.com/questions/5593761/how-to-set-the-transparency-color-for-toolbar-and-navigation-bar-using-monotouch

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