我有一个 Xamarin Forms 项目,我需要一个自定义按钮。该按钮看起来像这样:
我假设我需要创建一个自定义渲染器,但我不知道如何在按钮内拥有两种不同的字体大小?
我需要同时适用于 Android 和 iOS 的渲染器。任何帮助将不胜感激。谢谢!
最佳答案
如何跳过自定义渲染器并使用带有包含格式化文本的点击手势的 Frame
Label
:
<Frame VerticalOptions="Center" HorizontalOptions="Center" CornerRadius="10" BackgroundColor="Gray" BorderColor="Black">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="OnFrameTapped"/>
</Frame.GestureRecognizers>
<Label>
<Label.FormattedText>
<FormattedString>
<Span Text="2" FontSize="30" />
<Span Text="ABC" FontSize="15" />
</FormattedString>
</Label.FormattedText>
</Label>
</Frame>
关于android - 我需要在 Xamarin Forms 按钮内设置格式化文本(两种不同大小),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56926894/