简体   繁体   中英

Xamarin.Forms customizing action bar on iOS

I'm using Xamarin.Forms and on iOS I need to customize the top action bar. In this case I need to remove the dark line between the top action bar and the content view below (see screen shot). How can I do it ?

Thank you in advance!!

在此处输入图片说明

I did it here and it working:

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            //Tab bar
            UITabBar.Appearance.SelectedImageTintColor = UIColor.FromRGB(247, 139, 43); 
            //Switch
            UISwitch.Appearance.OnTintColor = UIColor.FromRGB(247, 139, 43);
            //----------------------------------------------------------------------------
            UINavigationBar.Appearance.BarTintColor = UIColor.Clear;
            UINavigationBar.Appearance.ShadowImage = new UIImage();
            UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
            //----------------------------------------------------------------------------                    
            global::Xamarin.Forms.Forms.Init();            
            ImageCircleRenderer.Init();                 
            LoadApplication(new App());

            return base.FinishedLaunching(app, options);
        }  

You can achieve this by either creating a custom Renderer:

[assembly: ExportRenderer(typeof(CustomNavigationPage), typeof(CustomNavigationRenderer))]
    namespaceiOS.Renderers
    {
        public class CustomNavigationRenderer : NavigationRenderer
        {

            public override void ViewDidLoad()
            {
                base.ViewDidLoad();

                this.NavigationBar.ShadowImage = new UIImage();
                this.NavigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
             }
          }
     }

Or in your iOS project, in AppDelegate method "FinishedLaunching" you could use the UIAppearance API to style your application across the board.

UINavigationBar.Appearance.ShadowImage = new UIImage();
UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM