2
votes

I have a Xamarin Forms project, and I need to have a custom button. The button would look something like this:

enter image description here

I assume I need to create a custom renderer, but I can't figure out how to have two different font sizes inside a button?

I need renderers for both Android and iOS. Any help would be greatly appreciated. Thanks!

1

1 Answers

4
votes

How about skipping the custom renderer and use a Frame w/ a tap gesture that encloses a formatted text 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>

enter image description here