Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Frame corner radius not rounding corners on iOS

I am trying to round the corners of a stack layout, it works on android but on iOS, they still appear square but it does display the Frame shadow

My XAML is

<ContentPage.Content>
    <StackLayout BackgroundColor="WHITE">
        <ListView>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout>
                            <Frame CornerRadius="10" Padding="0" Margin="10, 10, 10, 10">
                                <StackLayout>
                                    . . .
                                </StackLayout>
                            </Frame>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackLayout>
</ContentPage.Content>
like image 719
Dan Avatar asked Mar 04 '18 04:03

Dan


3 Answers

Set IsClippedToBounds property to Frame control:

<Frame IsClippedToBounds="True" CornerRadius="10" Padding="0" Margin="10, 10, 10, 10">
    <StackLayout>
    </StackLayout>
</Frame>
like image 120
Arvis Avatar answered Sep 30 '22 16:09

Arvis


they still appear square

Actually, the Frame is round not the StackLayout, we just use Frame wrap it ,so it looks the StackLayout has round corners.

Frame

<Frame CornerRadius="10" Padding="0" Margin="10, 10, 10, 10" HasShadow="False" BackgroundColor="Red">
    <StackLayout >
         <Label Text="{Binding}"/>
    </StackLayout>
</Frame>

enter image description here

StackLayout

<Frame CornerRadius="10" Padding="0" Margin="10, 10, 10, 10" HasShadow="False" >
   <StackLayout BackgroundColor="Red">
         <Label Text="{Binding}"/>
   </StackLayout>
</Frame>

enter image description here

it does display the Frame shadow

You can disable it by HasShadow="False".

like image 36
ColeX - MSFT Avatar answered Sep 30 '22 15:09

ColeX - MSFT


Actually I believe, it is a bug of Xamarin.Forms. UWP, Android and iOS should behave the same, but they don't. As a result to implement the same behaviour developers need to use OnPlatform feature.

The bug is described and discussed here, it is still open: https://github.com/xamarin/Xamarin.Forms/issues/2405

like image 31
Marat Gallyamov Avatar answered Sep 30 '22 15:09

Marat Gallyamov