[英]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.