首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NavigationBar.ShadowImage =新的UIImage()不删除xamarin.forms 4.5之后的阴影线

NavigationBar.ShadowImage =新的UIImage()不删除xamarin.forms 4.5之后的阴影线
EN

Stack Overflow用户
提问于 2020-04-15 06:24:40
回答 1查看 256关注 0票数 0

NavigationBar.ShadowImage =新的UIImage()在xamarin.forms 4.5之后的IOS上不删除阴影线。新的方法是什么?

我尝试了所有这些方法,但都不起作用。

代码语言:javascript
复制
   protected override void OnElementChanged(VisualElementChangedEventArgs e)
    {
        base.OnElementChanged(e);
        NavigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
        NavigationBar.ShadowImage = new UIImage();
        UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
        UINavigationBar.Appearance.ShadowImage = new UIImage();
    }
    public override void ViewDidLoad()
    {
        base.ViewDidLoad();
        UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
        UINavigationBar.Appearance.ShadowImage = new UIImage();
        NavigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
        NavigationBar.ShadowImage = new UIImage();
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-15 20:05:26

我这样解决了我的问题:

我的自定义导航页面

代码语言:javascript
复制
        public CustomNavigationPage(Xamarin.Forms.Page root) : base(root)
    {
        InitializeComponent();
        On<iOS>().SetHideNavigationBarSeparator(true);
    }

和导航页面渲染器

代码语言:javascript
复制
 public override void ViewWillAppear(bool animated)
    {
        base.ViewWillAppear(animated);

        if (Element is Xamarin.Forms.NavigationPage navigationPage)
        {
            if (navigationPage.OnThisPlatform().HideNavigationBarSeparator())
            {
                if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
                {
                    NavigationBar.StandardAppearance.ShadowColor = null;
                }
            }
        }
    }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61218265

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档