Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin.ios Xamarin iOS透明导航栏_Xamarin.ios_Navbar_Transparent - Fatal编程技术网

Xamarin.ios Xamarin iOS透明导航栏

Xamarin.ios Xamarin iOS透明导航栏,xamarin.ios,navbar,transparent,Xamarin.ios,Navbar,Transparent,需要有透明的导航栏 试过了,但没用。 有什么建议吗尽管如此,您的问题并不是完全描述性的,也不确定您希望通过在给定链接中说“不工作”来实现什么 在ViewController的各个覆盖方法中编写以下代码,在这些方法中,您希望仅为特定的ViewController实现透明的NavigationBar public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); if (Na

需要有透明的导航栏


试过了,但没用。


有什么建议吗

尽管如此,您的问题并不是完全描述性的,也不确定您希望通过在给定链接中说“不工作”来实现什么

ViewController
的各个覆盖方法中编写以下代码,在这些方法中,您希望仅为特定的
ViewController
实现透明的
NavigationBar

public override void ViewWillAppear(bool animated)
{
    base.ViewWillAppear(animated);
    if (NavigationController != null)
    {
        NavigationController.NavigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
        NavigationController.NavigationBar.ShadowImage = new UIImage();
        NavigationController.NavigationBar.Translucent = true;
        NavigationController.View.BackgroundColor = UIColor.Clear;
        NavigationController.NavigationBar.BackgroundColor = UIColor.Clear;
    }
}

public override void ViewWillDisappear(bool animated)
{
    base.ViewWillDisappear(animated);
    if (NavigationController != null)
    {
        NavigationController.NavigationBar.SetBackgroundImage(null, UIBarMetrics.Default);
        NavigationController.NavigationBar.ShadowImage = null;
        NavigationController.NavigationBar.BarTintColor = UIColor.Red; //Provide your specific color here
    }
}
如果要全局设置,请在
AppDelegate
FinishedLaunching
方法中尝试:

UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
UINavigationBar.Appearance.ShadowImage = new UIImage();
UINavigationBar.Appearance.BackgroundColor = UIColor.Clear;
UINavigationBar.Appearance.Translucent = true;

希望这有帮助

尽管如此,您的问题并不是完全描述性的,也不确定通过在给定链接中说“不起作用”,您到底想要达到什么目的

ViewController
的各个覆盖方法中编写以下代码,在这些方法中,您希望仅为特定的
ViewController
实现透明的
NavigationBar

public override void ViewWillAppear(bool animated)
{
    base.ViewWillAppear(animated);
    if (NavigationController != null)
    {
        NavigationController.NavigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
        NavigationController.NavigationBar.ShadowImage = new UIImage();
        NavigationController.NavigationBar.Translucent = true;
        NavigationController.View.BackgroundColor = UIColor.Clear;
        NavigationController.NavigationBar.BackgroundColor = UIColor.Clear;
    }
}

public override void ViewWillDisappear(bool animated)
{
    base.ViewWillDisappear(animated);
    if (NavigationController != null)
    {
        NavigationController.NavigationBar.SetBackgroundImage(null, UIBarMetrics.Default);
        NavigationController.NavigationBar.ShadowImage = null;
        NavigationController.NavigationBar.BarTintColor = UIColor.Red; //Provide your specific color here
    }
}
如果要全局设置,请在
AppDelegate
FinishedLaunching
方法中尝试:

UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
UINavigationBar.Appearance.ShadowImage = new UIImage();
UINavigationBar.Appearance.BackgroundColor = UIColor.Clear;
UINavigationBar.Appearance.Translucent = true;

希望这有帮助

在iOS中,单个导航栏用于特定的导航控制器。所以,如果你想让它对单个VC透明,那么当你导航到那个VC时,你必须让它透明。然后,当您从ViewWillEngase(或ViewDidEngase)方法中的VC返回时,将其更改回来

在iOS中,单个导航栏用于特定的导航控制器。所以,如果你想让它对单个VC透明,那么当你导航到那个VC时,你必须让它透明。然后,当您从ViewWillEngase(或ViewDidEngase)方法中的VC返回时,将其更改回来

谢谢@MilanG,我想让导航栏在特定的ViewController上透明。您的代码确实有效,但也影响了其他ViewController。我更新了答案,使ViewController特定于透明导航栏。谢谢@MilanG,我希望导航栏在特定的ViewController上透明。您的代码确实有效,但也影响了其他ViewController。我更新了答案,使ViewController特定于透明导航栏。