Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Button Image behaviour for iOS.

$
0
0

I have a strange issue with a Button image when rendered on IOS.

The image is a 32px x 32px PNG with no transparency. just 2 flat colours. However when it's rendered on the button in the iOS simulator (and physical device) it appears like this.

ios button image

It appears fine on both WP & Droid.

The button xaml is below...

 <Button x:Name="Scan"
              Text="Scan a QR Code"
              Image="QRCode.png"
              Command="{Binding ScanCode}"
              TextColor="{x:Static core:AppConstants.ButtonTextColor}"
              BackgroundColor="{x:Static core:AppConstants.ButtonBackgroundColor}">
      </Button>

I've tried to just remove the button image on iOS with the following xaml but both of these throw a null reference exception in the .g.cs file at the point it attempts to load the xaml.

      <Button x:Name="Scan"
              Text="Scan a QR Code"
              Command="{Binding ScanCode}"
              TextColor="{x:Static core:AppConstants.ButtonTextColor}"
              BackgroundColor="{x:Static core:AppConstants.ButtonBackgroundColor}">
        <Button.Image>
          <OnPlatform x:TypeArguments="FileImageSource">
            <OnPlatform.iOS></OnPlatform.iOS> //OMITTING THIS ALSO GIVES A NULL REF EXCEPTION
            <OnPlatform.Android>QRCode.png</OnPlatform.Android>
            <OnPlatform.WinPhone>QRCode.png</OnPlatform.WinPhone>
          </OnPlatform>
        </Button.Image>
      </Button>

Viewing all articles
Browse latest Browse all 58056

Trending Articles