0

I was using this code before, now this is not working. I am using gradient image to add on navigationbar background. This was working before xcode 11.4 update but after updating this has stoped working. Moreover title is also shown in black color. I tried changing color it didn't worked.

var img = UIImage.FromBundle("navbar_image").CreateResizableImage(UIEdgeInsets.Zero, UIImageResizingMode.Stretch);
NavigationController.NavigationBar.SetBackgroundImage(img, UIBarMetrics.Default);

This is before imgaeThis is before imgae

Now it is showing like this with title in black colorNow it is showing like this with title in black color

Zeeshan Shakil
  • 157
  • 2
  • 13
  • Try to use UINavigationBarAppearance to set the title color instead, you can have a look at [this thread](https://stackoverflow.com/questions/60848786/xcode-11-4-navigations-title-color-gone-black-from-storyboard). – nevermore Apr 03 '20 at 07:17

1 Answers1

0

This code worked for me.

if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
        {
            UINavigationBarAppearance appearance = new UINavigationBarAppearance();
            var img = UIImage.FromBundle("navbar_image").CreateResizableImage(UIEdgeInsets.Zero, UIImageResizingMode.Stretch);
            appearance.BackgroundImage = img;
            appearance.TitleTextAttributes = new UIStringAttributes { ForegroundColor = UIColor.White };
            appearance.BackgroundColor = UIColor.Blue;
            NavigationController.NavigationBar.CompactAppearance = appearance;
            NavigationController.NavigationBar.StandardAppearance = appearance;
            NavigationController.NavigationBar.ScrollEdgeAppearance = appearance;

        }
        else
        {
            var img = UIImage.FromBundle("navbar_image").CreateResizableImage(UIEdgeInsets.Zero, UIImageResizingMode.Stretch);
            NavigationController.NavigationBar.SetBackgroundImage(img, UIBarMetrics.Default);
            this.NavigationController.NavigationBar.Translucent = false;
        }
Zeeshan Shakil
  • 157
  • 2
  • 13