Obwohl Ihre Frage nicht vollständig beschreibend und nicht sicher ist, was genau Sie erreichen möchten, indem Sie "Nicht arbeiten" von dem gegebenen Link sagen.
Schreiben Sie den folgenden Code in die entsprechenden Überschreibungsmethoden des ViewController
, in dem Sie nur den Tranperent NavigationBar
für diesen spezifischen ViewController
erreichen möchten.
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
}
}
Wenn Sie diese global festlegen möchten, versuchen Sie es in AppDelegate
‚s FinishedLaunching
Methode:
UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
UINavigationBar.Appearance.ShadowImage = new UIImage();
UINavigationBar.Appearance.BackgroundColor = UIColor.Clear;
UINavigationBar.Appearance.Translucent = true;
hoffe, das hilft !.
Dank @MilanG, Nun, ich wollte die Navbar transparent auf bestimmte ViewController haben. Ihr Code hat funktioniert, aber es betrifft auch andere ViewControllers. –
Ich habe meine Antwort aktualisiert, um ViewController spezifische Transperent Navigationbar zu machen. – MilanG
Danke, es hat funktioniert! –