简体   繁体   English

将MasterDetailPage的背景设置为透明

[英]Setting the background of a MasterDetailPage to be transparent

When I try to set the background color of the Master (of the MasterDetailPage) to transparent, it stays white. 当我尝试将Master(MasterDetailPage)的背景颜色设置为透明时,它会保持白色。

Basically what I would want to see, is that the color from the detail page is shown through the Master. 基本上我想要看到的是,细节页面的颜色是通过Master显示的。

FOR EXAMPLE (If the above were true, then the background color of this MasterDetailPage would be red (Yes I know I can just set the background colour as red, but I want it to be transparent )) 例如 (如果以上都是真的,那么这个MasterDetailPage的背景颜色将是红色的(是的,我知道我可以将背景颜色设置为红色,但我希望它是透明的 ))

师父应该是红色的

After seeing the TabletMasterDetailRenderer's documentation , we can find that the master or detail page which we create in PCL will be added on the _masterController.View and _detailController.View . 在看到TabletMasterDetailRenderer的文档后 ,我们可以发现我们在PCL中创建的主页面或详细页面将添加到_masterController.View_detailController.View

So when we set its BackgroundColor to Transparent , the page will still be white as what we look. 因此,当我们将BackgroundColor设置为Transparent ,页面仍然是白色的。 We should also set the _masterController.View 's BackgroundColor . 我们还应该设置_masterController.ViewBackgroundColor

We can find the _masterController in renderer and set it like: 我们可以在渲染器中找到_masterController并将其设置为:

public override void ViewWillLayoutSubviews()
{
    base.ViewWillLayoutSubviews();

    var master = ViewControllers[0];
    master.View.BackgroundColor = UIColor.Clear;

    //This is Detail ViewController
    var detail = ViewController.ChildViewControllers[1];
}

Create a custom renderer for MasterDetailPage and put this code in it. MasterDetailPage创建自定义渲染器并将此代码放入其中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WPF将背景设置为透明和在控件上设置不透明度有什么区别? - WPF What is the difference between setting the background to transparent and setting opacity on the control? 如何在 MasterDetailPage 菜单中设置背景图片 - How to set Background image in MasterDetailPage menu 将SciChartSurface背景设置为透明可使其变成黑色Xamarin.Android - Setting SciChartSurface background to transparent makes it black Xamarin.Android 将我的PictureBox设置为透明的背景颜色并不能真正使其透明。 虫子? - Setting my PictureBox to transparent background color doesn't really make it transparent. Bug? MasterDetailPage 背景图像未显示在 xamarin.forms 中的 IOS 中 - MasterDetailPage background image not displaying in IOS in xamarin.forms 在 WinForms 中将标签背景颜色设置为透明使其忽略其下方的任何图像并显示表单背景图像 - Setting a label background colour to transparent in WinForms make it ignore any images underneath it and displays the form background image instead 具有透明背景的透明图像问题 - Issue with transparent images with a transparent background 具有透明背景的RadioButtonRenderer - RadioButtonRenderer with Transparent Background 文字的不透明背景 - Transparent background for text by opacity WPF透明背景 - WPF Transparent background
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM