簡體   English   中英

Xamarin.Forms自定義操作欄在iOS上

[英]Xamarin.Forms customizing action bar on iOS

我正在使用Xamarin.Forms,在iOS上,我需要自定義頂部操作欄。 在這種情況下,我需要刪除頂部操作欄和下面的內容視圖之間的暗線(請參見屏幕截圖)。 我該怎么做 ?

先感謝您!!

在此處輸入圖片說明

我在這里做到了,它的工作原理是:

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);
        }  

您可以通過創建自定義渲染器來實現:

[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);
             }
          }
     }

或在您的iOS項目中,通過AppDelegate方法“ FinishedLaunching”,您可以使用UIAppearance API對整個應用程序進行樣式設置。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM