【问题标题】:Xamarin.forms- Trouble with bottom shadow toolbar iosXamarin.forms - 底部阴影工具栏 ios 出现问题
【发布时间】:2020-03-31 15:26:23
【问题描述】:

我正在处理 Xamarin.forms 应用程序聊天,但在使用 NavigationBar 时遇到了一些问题。问题出在工具栏的阴影上,我希望它消失。

它已经在使用下面的代码,但现在它停止工作了。

图片 !enter image description here]1

代码 AppDelegate

        Xamarin.Forms.Forms.SetFlags(new string[] { "CarouselView_Experimental", "IndicatorView_Experimental" });
        ImageCircleRenderer.Init();
        KeyboardOverlapRenderer.Init();
        global::Xamarin.Forms.Forms.Init();
        LoadApplication(new App(null, null, null));
        OneSignal.Current.StartInit("8bf7b19d-fb86-4ffb-a17e-5998f6756883").HandleNotificationOpened(App.HandleNotificationOpened).EndInit();

        UINavigationBar.Appearance.ShadowImage = new UIImage();
        UITabBar.Appearance.SelectedImageTintColor = UIColor.FromRGB(255, 255, 255);

【问题讨论】:

    标签: ios xamarin.ios navigation uinavigationbar


    【解决方案1】:

    如果这不起作用,还有另一个解决方案可以通过自定义 NavigationPage 来实现它。

    创建一个CustomNavigationPage

    public class CustomNavigationPage : NavigationPage
    {
        public CustomNavigationPage(Page root) : base(root)
        {
        }
    }
    

    App.xaml.cs 中:

    public App()
    {
        InitializeComponent();
        CustomNavigationPage navigationPage = new CustomNavigationPage(new MainPage());
        MainPage = navigationPage;
    }
    

    然后在 iOS 解决方案中,您可以创建 CustomNavigationRenderer 来修改导航栏:

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

    效果如预期:

    【讨论】:

    • 没有用。会不会是一些阻止渲染的配置?
    • @RafaVieira 这将是可能的。你能分享 App.xaml.cs 代码吗,我会检查的。或者您可以创建一个新的示例项目来测试我的共享解决方案并首先检查它是否有效。
    • 它适用于一个新项目,我现在将比较并尝试找出可能发生的情况。
    • @RafaVieira 太好了!如果发现记得在这里分享:-)
    猜你喜欢
    • 1970-01-01
    • 2018-12-27
    • 2014-01-22
    • 2022-11-10
    • 2016-10-27
    • 2017-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多