Xamarin昏暗页面(主要详细信息页面) [英] Xamarin Dim Page (Master Detail Page)

查看:71
本文介绍了Xamarin昏暗页面(主要详细信息页面)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,对于Android,当显示母版详细信息页的母版页时,母版页上覆盖着黑色暗色"视图,因此很容易用眼睛区分两个页面.在iOS中,详细信息页面不会变暗,因此很难区分视图.有没有一种方法可以用BoxView或Frame覆盖黑色半透明"的详细信息页面,从而以类似于Android的方式使页面变暗.我曾尝试过多种不同的颜色和不透明的盒子视图,但它们都完全覆盖了屏幕,您无法透视它们".有任何想法吗?还是更好的解决方案?即使它是BoxView的客户渲染器也可以使用.我只需要颜色的想法/设置就可以使它透明.

So for Android when the master page of a master-detail page is shown the master page is covered with a "black dim" view so it is easy to differentiate the two pages with the eye. In iOS the detail page is not dimmed so it is tougher to differentiate the views. Is there a way to overlay the details page with a BoxView or Frame that is "black translucent" so it dims the page in similar fashion to Android. I have tried many different colors and opacities of a box view but they all completely cover the screen and you can't "see through them". Any ideas? Or better solutions? Even if it is a customer renderer for the BoxView that will work. I just need color ideas/settings to make it see through.

推荐答案

此处提供示例: https://github.com/jgold6/XamarinSupportSamples/tree/master/XForms-TestShadingiOSDetailPage

以下是防止链接中断的代码:

Here's the code in case the link ever breaks:

MasterDetailPage mdPage;
Color origContentBgColor;
Color origPageBgColor;

public App()
    {
        mdPage = new MasterDetailPage();
        mdPage.IsPresentedChanged += async (object sender, EventArgs e) => {
            if (Device.OS == TargetPlatform.iOS) {
                if (mdPage.IsPresented) {
                    var currentPage = (DetailPage)((NavigationPage)mdPage.Detail).CurrentPage;
                    origPageBgColor = currentPage.BackgroundColor;
                    origContentBgColor = currentPage.Content.BackgroundColor;

                    currentPage.BackgroundColor = Color.Black;
                    currentPage.Content.FadeTo(0.5);
                    if (currentPage.Content.BackgroundColor == Color.Default) {
                        currentPage.Content.BackgroundColor = Color.White;

                    }
                }
                else {
                    var currentPage = (DetailPage)((NavigationPage)mdPage.Detail).CurrentPage;
                    currentPage.BackgroundColor = origPageBgColor;
                    currentPage.Content.BackgroundColor = origContentBgColor;
                    currentPage.Content.FadeTo(1.0);
                }


            }
        };
        mdPage.Master = new MasterPage(){Title = "Master Page"};
        mdPage.Detail = new NavigationPage( new DetailPage());

        // The root page of your application
        MainPage = mdPage;
    }

这篇关于Xamarin昏暗页面(主要详细信息页面)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆