MAUI:如何使用Border StrokeShape属性绘制完美的圆形?

问题描述 投票:0回答:1

我最后的尝试是这样的:

<Border Stroke="#649B33"
        StrokeThickness="1"
        StrokeShape="Ellipse 30, 30"
        Padding="8"
        Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"
        HorizontalOptions="Center">
        <Label Text="1" FontAttributes="Bold" />
</Border>

关于

StrokeShape
属性的文档非常非常差,所以我试图猜测正确的方法,但实际上我花了太多时间并且没有任何效果。

你能告诉我如何使用

StrokeShape
属性来实现我所需要的吗?

maui
1个回答
1
投票

这对我有用

    <Border Stroke="#649B33"
            StrokeThickness="10"
            StrokeShape="Ellipse 40, 40"
            Padding="8"
            HorizontalOptions="Center">
        <Label HorizontalTextAlignment="Center"
               VerticalTextAlignment="Center" 
               WidthRequest="40" HeightRequest="40"
               Text="1" FontAttributes="Bold" />
    </Border>

我认为关键是为标签设置相同的宽度和高度值,使其成为正方形

© www.soinside.com 2019 - 2024. All rights reserved.