xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] navigationBarcolor and tabscolor in IOS is giving a lighter color when compared to original color & with android devices #9349

Closed uday-lucky closed 4 years ago

uday-lucky commented 4 years ago

Description

1.Navigationbar color & also the tabs background color is very light , when compared to the original color(#132241). It is fine in android . When i deploy in IOS, the color is very light and not matching the original.

  1. Also, there is a slight colour difference between the top tab bar background color and navigationbar color

Steps to Reproduce

  1. Download xaminals sample project from https://docs.microsoft.com/en-gb/samples/xamarin/xamarin-forms-samples/userinterface-xaminals/

  2. Replace "Shell.BackgroundColor" with "#132241" in "DomesticShell" style (AppShell.Xaml) as shown below.

<Style x:Key="DomesticShell" TargetType="Element" BasedOn="{StaticResource BaseStyle}"> <Setter Property="Shell.BackgroundColor" Value="#132241" />

  1. Just Deploy in android and Ios devices.

Expected Behavior

Screenshot 2020-01-29 at 12 32 13 AM

Same as the colour in android device

Actual Behavior

Screenshot 2020-01-29 at 12 30 40 AM

Difference in both platforms;

Screenshot 2020-01-29 at 12 32 39 AM

Basic Information

Screenshots

Screenshot 2020-01-29 at 12 32 39 AM

Reproduction Link

Workaround

I tried adding the following line in appdelegate.cs

       UINavigationBar.Appearance.Translucent = false;
        UITabBar.Appearance.BackgroundColor = UIColor.FromRGB(19, 34, 65);

succeeded in getting the navigationbar color and bottom tab background color , but the top tabbed page background color still appears different from original color. Please find below screenshot for reference.

Screenshot 2020-01-29 at 12 57 54 AM
PureWeen commented 4 years ago

duplicate https://github.com/xamarin/Xamarin.Forms/issues/6298

GeorgeVelikov commented 4 years ago

duplicate #6298

The workaround for the duplicate only affects the actual navbar and does not affect the top tab bar which the shell creates

samueljoos commented 4 years ago

6298 only works for the navigationbar.

I managed to fix it by creating a custom AppShellRenderer

using System;
using YourApp;
using YourApp.iOS.Renderers;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(AppShell), typeof(MyShellRenderer))]
namespace YourApp.iOS.Renderers
{
    public class TabbarAppearanceTracker : ShellTabBarAppearanceTracker
    {
        public override void SetAppearance(UITabBarController controller, ShellAppearance appearance)
        {
            controller.TabBar.Translucent = false;
            base.SetAppearance(controller, appearance);
        }
    }
    public class MyShellRenderer:ShellRenderer
    {
        protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()
        {
            return new TabbarAppearanceTracker();
        }
    }
}
AdamDiament commented 4 years ago

@samhouts I still have this issue in iOS using xamarin forms 4.6 - is this expected and going to be in a future release or should I raise another issue?