다음을 통해 공유


iOS의 셀 배경색

이 .NET 다중 플랫폼 앱 UI(.NET MAUI) iOS 플랫폼별 인스턴스의 Cell 기본 배경색을 설정합니다. 바인딩 가능한 속성을 Color다음으로 설정 Cell.DefaultBackgroundColor 하여 XAML에서 사용합니다.

<ContentPage ...
             xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls">
    <StackLayout Margin="20">
        <ListView ItemsSource="{Binding GroupedEmployees}"
                  IsGroupingEnabled="true">
            <ListView.GroupHeaderTemplate>
                <DataTemplate>
                    <ViewCell ios:Cell.DefaultBackgroundColor="Teal">
                        <Label Margin="10,10"
                               Text="{Binding Key}"
                               FontAttributes="Bold" />
                    </ViewCell>
                </DataTemplate>
            </ListView.GroupHeaderTemplate>
            ...
        </ListView>
    </StackLayout>
</ContentPage>

또는 흐름 API를 사용하여 C#에서 사용할 수 있습니다.

using Microsoft.Maui.Controls.PlatformConfiguration;
using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;
...

ViewCell viewCell = new ViewCell { View = ... };
viewCell.On<iOS>().SetDefaultBackgroundColor(Colors.Teal);

이 메서드는 ListView.On<iOS> 이 플랫폼별이 iOS에서만 실행되도록 지정합니다. 네임스페이 Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific 스의 메서드는 Cell.SetDefaultBackgroundColor 셀 배경색을 지정된 Color색으로 설정합니다. 또한 메서드를 Cell.DefaultBackgroundColor 사용하여 현재 셀 배경색을 검색할 수 있습니다.

그 결과 A의 배경색을 Cell 특정 Color색으로 설정할 수 있습니다.

Screenshot of the Teal group header cells, on iOS.