Xamarin.forms: [Bug] UINavigationBar.Appearance.BarTintColor not working when update 4.5 version

Created on 28 Feb 2020  路  40Comments  路  Source: xamarin/Xamarin.Forms

Description

Steps to Reproduce

  1. In Xamarin.iOS project. Added this code
    UINavigationBar.Appearance.BarTintColor = UIColor.FromPatternImage(UIImage.FromFile("toolbarBackground.png")); UINavigationBar.Appearance.TintColor = UIColor.White; UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes() { TextColor = UIColor.White });
  2. Build and Run

Expected Behavior

image

Actual Behavior

image

Basic Information

  • Version with issue: 4.5
  • Last known good version: 4.4
  • IDE:
  • Platform Target Frameworks:

    • iOS:

    • Android:

    • UWP:

  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices:

Screenshots

image

Reproduction Link

Workaround

navbar 5 regression in-progress iOS 馃崕 bug

Most helpful comment

Please fix asap, it's urgent.

All 40 comments

I'm experiencing exactly the same issue, and it only started today. Yesterday the colors were there.

I downgraded Xamarin.Forms to 4.4 and the problem went away. This morning I upgraded to 4.5. That seems to have caused the issue.

Same issue here just after upgrading to 4.5.0.356.
Trying to set this code in AppDelegate FinishedLaunching:
UINavigationBar.Appearance.BarTintColor = UIColor.FromPatternImage(UIImage.FromFile("toolbar_image.png"));

No exception, just nothing showing up in the toolbar as in the screenshots of haiduong741.

Same issue here. UINavigationBar.Appearance.BarTintColor not working.

Downgrade to v4.4 and issue goes away.

My guess would be this PR: https://github.com/xamarin/Xamarin.Forms/pull/9346

Out of curiosity, does the behavior change between iOS 13 and iOS <13?

Seems to be the same (or related) as https://github.com/xamarin/Xamarin.Forms/issues/9767

Duplicate of #9790

Any workaround for this? i need to go on production and i have already implemented some features from 4.5, and i don't want to revert all changes, because my last Xamarin.Forms was 4.3. Any Hacky CustomRenderer wouldn't fix this?

XF 4.5.0.396 doesn't fixed this issue. :(

So how do i release new app with new X.F on mac after april? (The depracated UIWebView issue) With this ugly app bar?

Please when is this coming out. It is not fixed in 4.5.0.396 ? Any other alternative, like setting something in custom renderer will fix this ? Can't till 4.7

Please fix asap, it's urgent.

Guys? The April is near...

Guys? The April is near...

Yes. April is comming. And I must choose between 2 options XF 4.5 remove UIWebView and 4.4 using Navigation has background.

But i don't have an option as one of my App is not published. So i have only option with XF 4.5 and this navigation bar. My QA and PM are asking me everyday about this bug because I have 4 buttons on navigation bar. (LeftItem for LoggingIn/Settings, Right buttons for Search, Chromecast, and Secondary Items). Also colors of this navigation bar can be changed, so there are 5 bad things that this bug is causing :(

I'm closing this because it is a duplicate of #9790. That issue has been resolved, and the fix will be released in a 4.5.0 service release today or tomorrow. Thanks for your patience!

I'm closing this because it is a duplicate of #9790. That issue has been resolved, and the fix will be released in a 4.5.0 service release today or tomorrow. Thanks for your patience!

@samhouts If possible, can you please post here once the fix is available on nuget as we are all following this conversation ?

4.5.0.495 does not seem to resolve the issue for me...

4.5.0.495 - still not working for me

Same here 4.5.0.495 - still not working for me

It should be available now! https://www.nuget.org/packages/Xamarin.Forms/4.5.0.495

why you close this when XF not fixed this issue in new version????

I'm closing this because it is a duplicate of #9790. That issue has been resolved, and the fix will be released in a 4.5.0 service release today or tomorrow. Thanks for your patience!

"and the fix will be released in a 4.5.0"
ridiculous 馃拑

4.5.0.495 - still not working for me

Hi @samhouts do you have any updates on this issue? :)

Hi, I have the same issue too.
We have to release 4.5 version (with new web view) but we cant because our navigation bar is broken...

@eevahr Thanks for the ping! We don't always see conversation on closed issues unless there is a specific ping, so I missed the comments saying this wasn't working.

I'll reopen this, and we'll take a look. Thanks!

Hola, is it possible to get a more spesific timeframe on this, i am really aching for an ios update and would love to know if this fix is going to be released in the next 24 hours or less. As you know as of today 4.4 is not an option 馃槵

If you have a version already in the store then you have until December regarding the UIWebView deprecation, so that should be no issue. We have a PR open for this issue now which will hopefully be merged soon. A release should then follow soon.

Nice, that's a load off, i totally missed that from the apple notice, Thanks!

You are lucky guy then :) One of my company's app is blocked by this right now :D 馃憤 馃

Please test with this package and let us know if your issue is still not resolved. Thanks!

Xamarin.Forms.4.5.0.1682.nupkg.zip

Please test with this package and let us know if your issue is still not resolved. Thanks!

Xamarin.Forms.4.5.0.1682.nupkg.zip

Thanks for your works. Im always following this issue. Tomorrow I will check this.

@samhouts
I was add your package. But it not fixed. :(
Xamarin.Form package 4.5.0.1682. IOS 13.3 Iphone 11 Pro Max
image
image

FYI
Set background Image it work fine. But when I set background gradient using custom NavigationPageRenderer it not show. Here my code


using CoreAnimation;
using CoreGraphics;
using FastMobile.Device.iOS;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(NavigationPage), typeof(CustomNavigationPageRenderer))]
namespace FastMobile.Device.iOS
{
    public class CustomNavigationPageRenderer : NavigationPageRenderer
    {
        public CustomNavigationPageRenderer() : base()
        {
        }

        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            UpdateGradientView();
        }

        private void UpdateGradientView()
        {
            var control = this.Element as NavigationPage;
            var gradientLayer = new CAGradientLayer();
            gradientLayer.Bounds = NavigationBar.Bounds;
            gradientLayer.Colors = new CGColor[] { control.RightColor.ToCGColor(), control.LeftColor.ToCGColor() };
            gradientLayer.EndPoint = new CGPoint(0.0, 0.5);
            gradientLayer.StartPoint = new CGPoint(1.0, 0.5);
            UIGraphics.BeginImageContext(gradientLayer.Bounds.Size);
            gradientLayer.RenderInContext(UIGraphics.GetCurrentContext());
            UIImage image = UIGraphics.GetImageFromCurrentImageContext();
            UIGraphics.EndImageContext();
            NavigationBar.SetBackgroundImage(image, UIBarMetrics.Default);
        }
    }
}

If you have a version already in the store then you have until December regarding the UIWebView deprecation, so that should be no issue. We have a PR open for this issue now which will hopefully be merged soon. A release should then follow soon.

My app is new app. So sad :(

@haiduong741 I found a workaround, not sure if this helps you. When instantiaing a new Navigation Page you can set the BarBackGroundColor and BarTextColor. Although if you have a Tint Color, Xamarin deprecated that property.
var page= new NavigationPage(page) { Title = "Test Navigation Page", IconImageSource = "Test.png", BarBackgroundColor = Color.Blue, BarTextColor = Color.White };
But if you have more than one Navigation Page and you want to set this on all pages, you can write a custom NavigationRenderer and apply the barbackground color and bar text color for the element which is a NavigationPage.
Hope this helps and also Xamarin fixes the issue soon, as it is not just UIWebview issue, there are other important issues they fixed with 4.5, and we need them too.

@ngalicoco

@haiduong741 I found a workaround, not sure if this helps you. When instantiaing a new Navigation Page you can set the BarBackGroundColor and BarTextColor. Although if you have a Tint Color, Xamarin deprecated that property.
var page= new NavigationPage(page) { Title = "Test Navigation Page", IconImageSource = "Test.png", BarBackgroundColor = Color.Blue, BarTextColor = Color.White };
But if you have more than one Navigation Page and you want to set this on all pages, you can write a custom NavigationRenderer and apply the barbackground color and bar text color for the element which is a NavigationPage.
Hope this helps and also Xamarin fixes the issue soon, as it is not just UIWebview issue, there are other important issues they fixed with 4.5, and we need them too.

Thanks for your answer. But this has issue when using custom background Gradient. Solid color is work fine.

Not fixed for me in 4.5.0.617

Have you cleaned bin/ obj/ in all projects? I麓m on 4.5.0.657 and it works fine for me.

On iOS 12 and large titles enabled, background image is still not rendered when overriding NavigationRenderer. You just see the white background.

public class BackgroundImageNavigationRenderer : NavigationRenderer
{
    public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        View.BackgroundColor = UIColor.Clear;
        NavigationBar.BackgroundColor = UIColor.Clear;

        var image = UIImage.FromFile(Xamarin.Forms.Application.Current.Resources["BackgroundImage"] as string);

        NavigationBar.BarTintColor = UIColor.FromPatternImage(image);
    }
}
Was this page helpful?
0 / 5 - 0 ratings