2014-10-31 119 views
1

我正在用VisualStudio/Xamarin开发iOS应用程序。我必须将导航栏上的透明度设置为100%。但让我解释这一切:Xamarin iOS导航栏100%透明

在第一个视图中的导航栏有这段代码设置背景图片:

var navigationImage = UIImage.FromFile("gradient.jpg"); 
UINavigationBar.Appearance.SetBackgroundImage(navigationImage, UIBarMetrics.Default); 

第一种观点得到了几个TableCell的项目,如果点击,详细视图显示出来。 在该详细视图中,导航栏应该完全透明!只有后退按钮和标题应该是剩余的。

我尝试了一切从translucent = yes到这个solution,我也在这里找到了stackoverflow。

我也尝试将颜色设置为第一个导航栏,然后在下一个视图上将其更改为另一种颜色,但是如果我回到firstview,导航栏颜色保持不变,即使我重写ViewWillAppear - 从第一个视图中设置BarTintColor的方法。

感谢您的帮助!

问候

回答

2

嗯,这是非常值得,我居然也跟着你的解决方案链接,并将其转换为Xamarin。如果我把下面的代码放在VC的ViewDidLoad中,导航栏是完全透明的;)

this.NavigationController.NavigationBar.SetBackgroundImage (new UIImage(), UIBarMetrics.Default); 
this.NavigationController.View.BackgroundColor = UIColor.Clear; 
this.NavigationController.NavigationBar.BackgroundColor = UIColor.Clear; 
this.NavigationController.NavigationBar.ShadowImage = new UIImage();