Forum Xamarin.iOS

Why does the same code produce different output on simulator and physical iPhone?

EasyGoingPatEasyGoingPat GBMember ✭✭✭

With no changes in code, I get different output on the Xamarin iOS iPhone 6 Simulator and my physical iPhone 6.

This is the code that styles the buttons in the two attached screenshots:

public static Style Button_PrimaryActionStyle = new Style( typeof(Button) )
{
    Setters =
    {
        new Setter { Property = Button.FontSizeProperty, Value = 24 },
        new Setter { Property = Button.BorderWidthProperty, Value = 1 },
        new Setter { Property = Button.CornerRadiusProperty, Value = 22 },
        new Setter { Property = Button.PaddingProperty, Value = new Thickness( 3, 10 ) },
        new Setter { Property = Button.TextColorProperty, Value = Color.White },
        new Setter { Property = Button.BackgroundColorProperty, Value = Color.AliceBlue },
        new Setter { Property = Button.BorderColorProperty, Value = Color.Blue }
    }
};

(NOTE: I have changed the colours from the screenshots to remove external dependencies.)

Can anyone suggest why I am seeing different output? Unfortunately, the simulator is the one I want, so I have to figure out how to remove the underlines from the text on the physical iPhone.

  • Patrick


Best Answer

  • LandLuLandLu Member, Xamarin Team Xamurai
    Accepted Answer

    Please check the setting of your physical device. Did you check on the button shapes?
    A normal button won't have an underline style if you didn't set it programmatically even though on iOS 12.

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    I used your style on my side but it displays like:

    Different OS versions may cause different appearances. Does the simulator have the same version as your physical device?

  • EasyGoingPatEasyGoingPat GBMember ✭✭✭

    @LandLu

    Simulator is 13.4. Physical device is 12.4.6. So you are probably quite right. Strange that the simulator never showed an underline before now, even when it was way back on iOS versions less than 12.

    Don't suppose I could press you for a quick pointer on the best way to get rid of the underline? Am I looking at a custom renderer?

    Thank you for your reply.

    • Patrick
  • LandLuLandLu Member, Xamarin Team Xamurai
    Accepted Answer

    Please check the setting of your physical device. Did you check on the button shapes?
    A normal button won't have an underline style if you didn't set it programmatically even though on iOS 12.

  • EasyGoingPatEasyGoingPat GBMember ✭✭✭

    @LandLu

    Well, fixes don't get any easier (or any more embarrassing than that)! I wasn't even aware of such a setting. Thank you! That's probably saved me a few hours of pointless work.

Sign In or Register to comment.