删除Xamarin.forms中的导航栏阴影/线

时间:2017-07-07 12:58:58

标签: xamarin.forms

如何在Xamarin.forms中删除导航栏阴影和内容行页面。 是否可以在不渲染的情况下执行此操作。

3 个答案:

答案 0 :(得分:1)

在您的xamarin ios项目中添加此渲染类

[assembly: ExportRenderer(typeof(NavigationPage), typeof(CustomNavigationRenderer))]
namespace YOUR_IOS_NAMESPACE
{
    public class CustomNavigationRenderer : NavigationRenderer
    {
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            NavigationBar.ShadowImage = new UIImage(); 
        }
    }
}

答案 1 :(得分:0)

要删除底部阴影线,可以使用自定义渲染器。这将完全满足您的需求。特别是针对iOS和android OS,需要另找

[assembly: ExportRenderer(typeof(NavigationPage), typeof(NoLineNavigationRenderer))] 
namespace MyMobileProject.iOS {
    public class NoLineNavigationRenderer : NavigationRenderer {

        public override void ViewDidLoad(){
            base.ViewDidLoad();
            // remove lower border and shadow of the navigation bar
            NavigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
            NavigationBar.ShadowImage = new UIImage ();
        }
    }
}

答案 2 :(得分:0)

仅适用于Xamarin Forms,iOS。将此添加到您的AppDelegate

 UINavigationBar.Appearance.ShadowImage = new UIImage(); //No line under the navigation
相关问题