当它背后的内容时,iOS上的appshell tabar颜色会更改

发布于 2025-02-13 10:06:50 字数 11708 浏览 1 评论 0原文

我遇到与此问题。塔巴尔后面有内容时会更改颜色。但是,如这个问题所述,如果他们删除了渲染器,那么他们的问题就会停止。我目前根本没有渲染器,仍然有这个问题。我代码中没有此问题的唯一部分是页面不在shell层次结构中,并且已导航到使用以下代码行:

var search = new SearchList();
Navigation.PushAsync(search);

导航到使用以下代码的样式的页面TABBAR问题:

await Shell.Current.GoToAsync($"//{nameof(MemberList)}");

不同页面背后的XAML和代码完全相同。唯一的区别是一个在Appshell层次结构(会员列表)中定义一个,另一个不是(搜索清单),如下所示:

<Shell xmlns="http://xamarin.com/schemas/2014/forms" 
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       xmlns:local="clr-namespace:SampleYE.Views"
       Title="SampleYE"
       x:Class="SampleYE.AppShell"
      >

    <!--
        The overall app visual hierarchy is defined here, along with navigation.
    
        https://learn.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/
    -->

    <Shell.Resources>
        <ResourceDictionary>
            <Style x:Key="BaseStyle" TargetType="Element">
                <Setter Property="Shell.BackgroundColor" Value="{StaticResource Primary}" />
                <Setter Property="Shell.ForegroundColor" Value="{StaticResource Secondary}" />
                <Setter Property="Shell.TitleColor" Value="{StaticResource Secondary}" />
                <Setter Property="Shell.DisabledColor" Value="#AD94BB" />
                <Setter Property="Shell.UnselectedColor" Value="{StaticResource Tertiary}" />
                <Setter Property="Shell.TabBarBackgroundColor" Value="{StaticResource Primary}" />
                <Setter Property="Shell.TabBarForegroundColor" Value="{StaticResource Secondary}"/>
                <Setter Property="Shell.TabBarUnselectedColor" Value="{StaticResource Tertiary}"/>
                <Setter Property="Shell.TabBarTitleColor" Value="{StaticResource Secondary}"/>
            </Style>
            <Style TargetType="TabBar" BasedOn="{StaticResource BaseStyle}" />
            <Style TargetType="FlyoutItem" BasedOn="{StaticResource BaseStyle}" />
        </ResourceDictionary>
    </Shell.Resources>

    <TabBar>
        <ShellContent Route="StartupPage" Shell.FlyoutBehavior="Disabled" ContentTemplate="{DataTemplate local:StartupPage}" />
    </TabBar>

    <TabBar>
        <Tab Title="Directory" Icon="icon_feed.png">
            <ShellContent  Route="MemberList" ContentTemplate="{DataTemplate local:MemberList}"/>
        </Tab> 
        <Tab Title="Profile" Icon="icon_about.png">
            <ShellContent Route="ProfilePage1" ContentTemplate="{DataTemplate local:ProfilePage1}" />
        </Tab>                  
    </TabBar>

    <!--
        If you would like to navigate to this content you can do so by calling
        await Shell.Current.GoToAsync("//LoginPage");
    -->
    <TabBar>
        <ShellContent Route="LoginPage1" Shell.FlyoutBehavior="Disabled" ContentTemplate="{DataTemplate local:LoginPage1}" />
    </TabBar>


</Shell>

与该问题的页面的定义如下:

<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="SampleYE.Views.MemberList">
    <ContentPage.Content>
        <ListView x:Name="listView" ItemSelected="OnItemSelected" IsGroupingEnabled="true">
            <ListView.GroupHeaderTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout Padding="5,0,0,0" VerticalOptions="StartAndExpand" Orientation="Vertical">
                            <Label Text="{Binding Title}" VerticalTextAlignment="Center" />
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.GroupHeaderTemplate>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout HorizontalOptions="StartAndExpand" Orientation="Horizontal">
                            <Image WidthRequest="44" HeightRequest="44" Source="{Binding Photo}" />
                            <StackLayout Padding="5,0,0,0" VerticalOptions="StartAndExpand" Orientation="Vertical">
                                <Label Text="{Binding Name}" VerticalTextAlignment="Center" Font="Medium" />
                                <Label Text="{Binding Title}" VerticalTextAlignment="Center" Font="Micro" />
                            </StackLayout>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </ContentPage.Content>
</ContentPage>
<ContentPage.Content>
        <Grid RowDefinitions="Auto">

                <ScrollView Grid.Row="0" >
                    <Grid RowDefinitions="Auto,Auto,Auto,Auto" ColumnDefinitions="*,*" VerticalOptions="CenterAndExpand"
                            RowSpacing="25">
                            <Frame Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" BorderColor="{StaticResource Secondary}"
                                    VerticalOptions="Start" HorizontalOptions="Center" WidthRequest="150" HeightRequest="150"
                                    CornerRadius="75" HasShadow="False" Padding="0" IsClippedToBounds="True">
                                <Image Source="Profile" Aspect="AspectFill"/>
                            </Frame>
                            <Button Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" 
                                TextColor="{StaticResource Primary}" BackgroundColor="{StaticResource Secondary}"
                                HeightRequest="54" WidthRequest="54" CornerRadius="27" TranslationX="65"
                                ImageSource="Camera" HorizontalOptions="Center" VerticalOptions="End"/>
                
                            <Frame Grid.Row="2" Grid.ColumnSpan="2" IsClippedToBounds="True"
                                Margin="20,20,20,0" CornerRadius="15" Padding="0,20,0,20"    >
                                <Grid RowDefinitions="*,*,*" ColumnDefinitions="*,*,*,*" RowSpacing="12" ColumnSpacing="5">
                                    <Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                            Text="Calvin"/>
                                    <Label Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                            Text="Carter"/>
                                    <Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                          Text="Ace"/>
                                    <Label Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                           Text="Wrecking Ball"/>
                                    <Label Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                            Text="Spring"/>
                                    <Label Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                            Text="2014"/>
                                </Grid>
                            </Frame>
                 
                            <Frame Grid.Row="3" Grid.ColumnSpan="2" IsClippedToBounds="False"
                                    Margin="20,20,20,0" CornerRadius="15" Padding="0,20,0,45" >
                                    <Grid RowDefinitions="*,Auto,Auto,*" ColumnDefinitions="*,*,*,*" RowSpacing="20" ColumnSpacing="5" >
                                        <Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" HorizontalTextAlignment="Center"
                                             Text="02/01/1994"/>
                                        <Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" HorizontalTextAlignment="Center"
                                             Text="Wreckingball14"/>
                                        <Label Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                             Text="[email protected]"/>
                                        <Label Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                                 Text="Wrecking Ball"/>
                                        <Label Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                              Text="Spring"/>
                                         <Label Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                              Text="2014"/>
                                     </Grid>
                             </Frame>
                  
                            <Grid
                                 Grid.Row="4" Grid.ColumnSpan="2" IsClippedToBounds="False"
                                Margin="20,0,20,0"  Padding="0,20,0,20"
                                    RowDefinitions="Auto,Auto" ColumnDefinitions="*,*" RowSpacing="20" >
                        
                                <Frame IsClippedToBounds="true" Grid.Row="0" Grid.ColumnSpan="2" 
                                           Padding="0"
                                         CornerRadius="15">
                                      <Editor HeightRequest="70" x:Name="interestEntry"
                                              BackgroundColor="{StaticResource Primary}" TextColor="{StaticResource Secondary}"
                                             Placeholder="Interests (i.e. UFC, Fishing, Investing etc;)"
                                             PlaceholderColor="{StaticResource Secondary}"/>

                                </Frame >
                
                                <Frame IsClippedToBounds="true" Grid.Row="1" Grid.ColumnSpan="2"
                                     Padding="0"
                                     CornerRadius="15">
                                    <Editor  HeightRequest="140" x:Name="bioEntry" 
                                        BackgroundColor="{StaticResource Primary}" TextColor="{StaticResource Secondary}"
                                       Placeholder="Biography (A little information about yourself)"
                                       PlaceholderColor="{StaticResource Secondary}"/>
                                </Frame>
                        
                            </Grid>
                
                    </Grid>

            
                </ScrollView>
        
                
          
        </Grid>
    </ContentPage.Content>

I have the exact same issue as asked in this question. The tabbar changes color when there is content behind it. However, as stated in this question, if they remove the renderer then their problem stops. I currently do not have a renderer at all and still have this problem. The only part of my code that doesn't have this problem are pages that are not in the shell hierarchy and that are navigated to using the following line of code:

var search = new SearchList();
Navigation.PushAsync(search);

The pages that are navigated to using the style of the following lines of code have the tabbar issue:

await Shell.Current.GoToAsync(
quot;//{nameof(MemberList)}");

The xaml and code behind for the different pages are the exact same. The only difference is one is defined in the appshell hierarchy(MemberList) and the other is not(SearchList) as seen below:

<Shell xmlns="http://xamarin.com/schemas/2014/forms" 
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       xmlns:local="clr-namespace:SampleYE.Views"
       Title="SampleYE"
       x:Class="SampleYE.AppShell"
      >

    <!--
        The overall app visual hierarchy is defined here, along with navigation.
    
        https://learn.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/
    -->

    <Shell.Resources>
        <ResourceDictionary>
            <Style x:Key="BaseStyle" TargetType="Element">
                <Setter Property="Shell.BackgroundColor" Value="{StaticResource Primary}" />
                <Setter Property="Shell.ForegroundColor" Value="{StaticResource Secondary}" />
                <Setter Property="Shell.TitleColor" Value="{StaticResource Secondary}" />
                <Setter Property="Shell.DisabledColor" Value="#AD94BB" />
                <Setter Property="Shell.UnselectedColor" Value="{StaticResource Tertiary}" />
                <Setter Property="Shell.TabBarBackgroundColor" Value="{StaticResource Primary}" />
                <Setter Property="Shell.TabBarForegroundColor" Value="{StaticResource Secondary}"/>
                <Setter Property="Shell.TabBarUnselectedColor" Value="{StaticResource Tertiary}"/>
                <Setter Property="Shell.TabBarTitleColor" Value="{StaticResource Secondary}"/>
            </Style>
            <Style TargetType="TabBar" BasedOn="{StaticResource BaseStyle}" />
            <Style TargetType="FlyoutItem" BasedOn="{StaticResource BaseStyle}" />
        </ResourceDictionary>
    </Shell.Resources>

    <TabBar>
        <ShellContent Route="StartupPage" Shell.FlyoutBehavior="Disabled" ContentTemplate="{DataTemplate local:StartupPage}" />
    </TabBar>

    <TabBar>
        <Tab Title="Directory" Icon="icon_feed.png">
            <ShellContent  Route="MemberList" ContentTemplate="{DataTemplate local:MemberList}"/>
        </Tab> 
        <Tab Title="Profile" Icon="icon_about.png">
            <ShellContent Route="ProfilePage1" ContentTemplate="{DataTemplate local:ProfilePage1}" />
        </Tab>                  
    </TabBar>

    <!--
        If you would like to navigate to this content you can do so by calling
        await Shell.Current.GoToAsync("//LoginPage");
    -->
    <TabBar>
        <ShellContent Route="LoginPage1" Shell.FlyoutBehavior="Disabled" ContentTemplate="{DataTemplate local:LoginPage1}" />
    </TabBar>


</Shell>

The definition of the pages with the issue are as follows:

<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="SampleYE.Views.MemberList">
    <ContentPage.Content>
        <ListView x:Name="listView" ItemSelected="OnItemSelected" IsGroupingEnabled="true">
            <ListView.GroupHeaderTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout Padding="5,0,0,0" VerticalOptions="StartAndExpand" Orientation="Vertical">
                            <Label Text="{Binding Title}" VerticalTextAlignment="Center" />
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.GroupHeaderTemplate>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout HorizontalOptions="StartAndExpand" Orientation="Horizontal">
                            <Image WidthRequest="44" HeightRequest="44" Source="{Binding Photo}" />
                            <StackLayout Padding="5,0,0,0" VerticalOptions="StartAndExpand" Orientation="Vertical">
                                <Label Text="{Binding Name}" VerticalTextAlignment="Center" Font="Medium" />
                                <Label Text="{Binding Title}" VerticalTextAlignment="Center" Font="Micro" />
                            </StackLayout>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </ContentPage.Content>
</ContentPage>
<ContentPage.Content>
        <Grid RowDefinitions="Auto">

                <ScrollView Grid.Row="0" >
                    <Grid RowDefinitions="Auto,Auto,Auto,Auto" ColumnDefinitions="*,*" VerticalOptions="CenterAndExpand"
                            RowSpacing="25">
                            <Frame Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" BorderColor="{StaticResource Secondary}"
                                    VerticalOptions="Start" HorizontalOptions="Center" WidthRequest="150" HeightRequest="150"
                                    CornerRadius="75" HasShadow="False" Padding="0" IsClippedToBounds="True">
                                <Image Source="Profile" Aspect="AspectFill"/>
                            </Frame>
                            <Button Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" 
                                TextColor="{StaticResource Primary}" BackgroundColor="{StaticResource Secondary}"
                                HeightRequest="54" WidthRequest="54" CornerRadius="27" TranslationX="65"
                                ImageSource="Camera" HorizontalOptions="Center" VerticalOptions="End"/>
                
                            <Frame Grid.Row="2" Grid.ColumnSpan="2" IsClippedToBounds="True"
                                Margin="20,20,20,0" CornerRadius="15" Padding="0,20,0,20"    >
                                <Grid RowDefinitions="*,*,*" ColumnDefinitions="*,*,*,*" RowSpacing="12" ColumnSpacing="5">
                                    <Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                            Text="Calvin"/>
                                    <Label Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                            Text="Carter"/>
                                    <Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                          Text="Ace"/>
                                    <Label Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                           Text="Wrecking Ball"/>
                                    <Label Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                            Text="Spring"/>
                                    <Label Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                            Text="2014"/>
                                </Grid>
                            </Frame>
                 
                            <Frame Grid.Row="3" Grid.ColumnSpan="2" IsClippedToBounds="False"
                                    Margin="20,20,20,0" CornerRadius="15" Padding="0,20,0,45" >
                                    <Grid RowDefinitions="*,Auto,Auto,*" ColumnDefinitions="*,*,*,*" RowSpacing="20" ColumnSpacing="5" >
                                        <Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" HorizontalTextAlignment="Center"
                                             Text="02/01/1994"/>
                                        <Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" HorizontalTextAlignment="Center"
                                             Text="Wreckingball14"/>
                                        <Label Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                             Text="[email protected]"/>
                                        <Label Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                                 Text="Wrecking Ball"/>
                                        <Label Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                              Text="Spring"/>
                                         <Label Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="2" HorizontalTextAlignment="Center"
                                              Text="2014"/>
                                     </Grid>
                             </Frame>
                  
                            <Grid
                                 Grid.Row="4" Grid.ColumnSpan="2" IsClippedToBounds="False"
                                Margin="20,0,20,0"  Padding="0,20,0,20"
                                    RowDefinitions="Auto,Auto" ColumnDefinitions="*,*" RowSpacing="20" >
                        
                                <Frame IsClippedToBounds="true" Grid.Row="0" Grid.ColumnSpan="2" 
                                           Padding="0"
                                         CornerRadius="15">
                                      <Editor HeightRequest="70" x:Name="interestEntry"
                                              BackgroundColor="{StaticResource Primary}" TextColor="{StaticResource Secondary}"
                                             Placeholder="Interests (i.e. UFC, Fishing, Investing etc;)"
                                             PlaceholderColor="{StaticResource Secondary}"/>

                                </Frame >
                
                                <Frame IsClippedToBounds="true" Grid.Row="1" Grid.ColumnSpan="2"
                                     Padding="0"
                                     CornerRadius="15">
                                    <Editor  HeightRequest="140" x:Name="bioEntry" 
                                        BackgroundColor="{StaticResource Primary}" TextColor="{StaticResource Secondary}"
                                       Placeholder="Biography (A little information about yourself)"
                                       PlaceholderColor="{StaticResource Secondary}"/>
                                </Frame>
                        
                            </Grid>
                
                    </Grid>

            
                </ScrollView>
        
                
          
        </Grid>
    </ContentPage.Content>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

知足的幸福 2025-02-20 10:06:50

解决此问题的方法是将我的iOS项目更新为较新版本。他们在更新中修复了它。

The fix to this was updating my ios project to a newer version. they fixed it in the update.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文