【问题标题】:Transparency not rendering the same on xamarin.ios project透明度在 xamarin.ios 项目上呈现不一样
【发布时间】:2018-07-31 10:45:32
【问题描述】:

我只是不明白为什么我在 xamarin 表单上的侧边菜单的背景不会在我的 xamarin.ios 上呈现相同。然而,在项目的其他部分中,当我使用透明背景时,我的列表视图呈现并看起来相同,我什至尝试从项目的其他部分复制和粘贴 xaml 代码,但它仍然无法正常工作。万一有人想知道客户端请求了ios上的侧边菜单。

附在下面,我有 2 张图片显示了侧边菜单在 2 个平台上的呈现方式不同

这是我用于侧边菜单的 Xaml 代码:

<MasterDetailPage.Master>
        <StackLayout Orientation="Vertical" BackgroundColor="Transparent" Spacing="0">
            <StackLayout
                HorizontalOptions="Fill"
                Orientation="Horizontal"
                VerticalOptions="Fill" BackgroundColor="Black" Padding="50, 50, 50, 50">
                <StackLayout HorizontalOptions="Center" Orientation="Vertical">
                    <ffimageloading:CachedImage x:Name="ProfilePictureCircleImage" 
                                                LoadingPlaceholder="profile_image_placeholder.png" 
                                                ErrorPlaceholder="profile_image_placeholder.png" 
                                                DownsampleToViewSize="true"
                                                FadeAnimationEnabled="true"
                                                HeightRequest="65"
                                                WidthRequest="65">
                <ffimageloading:CachedImage.Transformations>
                    <fftransformations:CircleTransformation/>
                </ffimageloading:CachedImage.Transformations>
                     </ffimageloading:CachedImage>
                </StackLayout>
                <StackLayout
                    HorizontalOptions="CenterAndExpand"
                    Orientation="Vertical"
                    VerticalOptions="CenterAndExpand">
                    <Label
                        x:Name="FullNameLabel"
                        FontSize="18"
                        HorizontalOptions="Center"
                        TextColor="White"
                        VerticalOptions="CenterAndExpand" />
                </StackLayout>
            </StackLayout>
    <BoxView HeightRequest="2" BackgroundColor="#D90B31"/>

         <ListView
                x:Name="NavigationMenuItems"
                ItemSelected="OnMenuItemSelected"
                BackgroundColor="{StaticResource TileColour}"
                RowHeight="60"
                SeparatorVisibility="None"
                SeparatorColor="Transparent">

                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <!--  Main design for menu items  -->


                            <StackLayout
                                Padding="20,10,0,10"
                                Orientation="Horizontal"
                                Spacing="20"
                                VerticalOptions="FillAndExpand"
                                BackgroundColor="Transparent">


           <local:TintedCachedImage TintColor="{StaticResource SideMenuIconColor}" 
                                    Source="{Binding Icon}" 
                                    VerticalOptions="Center"
                                    DownsampleToViewSize="true"
                                    HeightRequest="19" 
                                    WidthRequest="19"/>
                                <Label
                                    FontSize="15"
                                    Text="{Binding Title}"
                                    TextColor="{StaticResource SideMenuTextColor}"
                                    VerticalOptions="Center" />
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </StackLayout>
    </ContentPage>
</MasterDetailPage.Master>

<MasterDetailPage.Detail>
    <NavigationPage />
</MasterDetailPage.Detail>

以上图片展示了它在 2 个平台上的外观。

【问题讨论】:

    标签: xamarin xamarin.ios


    【解决方案1】:

    在另一个 stackoverflow thread 上找到了这个问题的解决方案我不得不使用自定义渲染器:

    public class CustomSideMenuRenderer: TabletMasterDetailRenderer
    {
        public override void ViewWillLayoutSubviews()
        {
            base.ViewWillLayoutSubviews();
    
            var master = ViewControllers[0];
            master.View.BackgroundColor = UIColor.Clear;
            var detail = ViewController.ChildViewControllers[1];
    
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2010-12-19
      • 2015-06-27
      • 2021-07-20
      • 1970-01-01
      • 1970-01-01
      • 2022-01-24
      • 1970-01-01
      • 2021-04-10
      • 2017-07-11
      相关资源
      最近更新 更多