简体   繁体   English

Xamarin 为 iOS 形成圆形图像

[英]Xamarin Forms Rounded Images For iOS

I can only see the rounded images in Android, I tried it on iOS and they appear as squares.我只能在 Android 中看到圆形图像,我在 iOS 上尝试过,它们显示为正方形。

            <StackLayout>
                         <RelativeLayout>
                            <Frame CornerRadius="60" 
                                  HeightRequest="{OnIdiom Phone=190,Tablet=355}"
                                  WidthRequest="{OnIdiom Phone=380,Tablet=710}"
                                  HorizontalOptions="Center"
                                  Padding="0"
                                  IsClippedToBounds="True"
                                  RelativeLayout.XConstraint="{OnIdiom Phone=15,Tablet=30}"
                                  RelativeLayout.YConstraint="{OnIdiom Phone=30,Tablet=30}">
                              <Image Source="kuwait3.jpg" 
                                     HorizontalOptions="Center"
                                     VerticalOptions="Center"
                                     RelativeLayout.HeightConstraint="{OnIdiom Phone=70,Tablet=310}"
                                     RelativeLayout.WidthConstraint="{OnIdiom Phone=70,Tablet=500}"/>
                            </Frame>
                        </RelativeLayout>
                    </StackLayout>

You should make your frame round and then your image will be round too:您应该使框架变圆,然后您的图像也会变圆:

<StackLayout>
    <RelativeLayout>
        <Frame CornerRadius="95" 
                              HeightRequest="{OnIdiom Phone=190,Tablet=355}"
                              WidthRequest="{OnIdiom Phone=190,Tablet=710}"
                              HorizontalOptions="Center"
                              Padding="0"
                              IsClippedToBounds="True"
                              RelativeLayout.XConstraint="{OnIdiom Phone=15,Tablet=30}"
                              RelativeLayout.YConstraint="{OnIdiom Phone=30,Tablet=30}">
            <Image Source="Images1" 
                                 HorizontalOptions="Center"
                                 VerticalOptions="Center"
                                 RelativeLayout.HeightConstraint="{OnIdiom Phone=70,Tablet=310}"
                                 RelativeLayout.WidthConstraint="{OnIdiom Phone=70,Tablet=500}"/>
        </Frame>
    </RelativeLayout>
</StackLayout>

The HeightRequest and WidthRequest should be same, and the CornerRadius should be half of HeightRequest/WidthRequest . HeightRequestWidthRequest应该相同,并且CornerRadius应该是HeightRequest/WidthRequest一半。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM