У меня проблемы с использованием CornerRadius в Xamarin.Forms. Я хочу иметь ImageButton и Frame (который содержит изображение), которые имеют CornerRadius = 100. Это прекрасно работает на Android, но не работает должным образом при запуске на iOS: рамка больше не является кругом и кнопка ImageButton исчезает.
Изображение iOS и Android Эмулятор
Мой код:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="FrameTest.MainPage"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <ImageButton Grid.Row="0" Grid.Column="0" BackgroundColor="#fc85ae" CornerRadius="100" Padding="2" Source="settings_wheel.png" HeightRequest="40" WidthRequest="40" HorizontalOptions="End"/> <Frame Grid.Row="1" Grid.Column="0" BorderColor="Black" CornerRadius="100" HeightRequest="100" WidthRequest="100" IsClippedToBounds="True" HorizontalOptions="Center" VerticalOptions="Center"> <Image x:Name="ProfilePictureView" BackgroundColor="#fc85ae" /> </Frame> </Grid>
Xamarin.Essentials: 1.3.1 Xamarin.Forms: 4.3.0.908675
Да, работает на Android, но не на iOS. Чтобы получить круг на обеих платформах, вы должны разделить HeightRequest / 2. Это ваш правильный CornerRadius.