This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 40251 - Cannot style Buttons natively using UIButton.Appearance
Summary: Cannot style Buttons natively using UIButton.Appearance
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS (show other bugs)
Version: unspecified
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-04-08 22:43 UTC by Joe Manke
Modified: 2017-03-20 16:01 UTC (History)
5 users (show)

See Also:
Tags: ac iOS
Is this bug a regression?: ---
Last known good build:


Attachments
Reproduction with workaround renderer (11.85 KB, application/zip)
2016-04-08 22:47 UTC, Joe Manke
Details

Description Joe Manke 2016-04-08 22:43:44 UTC
OVERVIEW: 
Attempts to use the Appearance proxy in native iOS to style buttons fails, due to the use of UIButtonType.RoundedRect when constructing the native control in the default ButtonRenderer.  UIButtonType.RoundedRect was deprecated in iOS 7, and replaced by UIButtonType.System, which ignores properties from the Appearance. Therefore, using the Appearance property to attempt to style buttons in a Xamarin.Forms app fails.

EXPECTED BEHAVIOR:
When properties are set on UIButton.Appearance, Button properties should match this when not set explicitly otherwise.

ACTUAL BEHAVIOR:
Button properties do not match UIButton.Appearance.

Example: 
> UIButton.Appearance.SetTintColor(UIColor.Red, UIControlState.Normal);
Default Button.TextColor appears as blue.

SOLUTION: 
In the ButtonRenderer, replace
> this.SetNativeControl(new UIButton(UIButtonType.RoundedRect));
with
> this.SetNativeControl(new UIButton(UIButtonType.Custom));

WORKAROUND:
Extend ButtonRenderer, use UIButton.Appearance in default cases. See attachment.

RELATED: https://bugzilla.xamarin.com/show_bug.cgi?id=25209
Comment 1 Joe Manke 2016-04-08 22:47:40 UTC
Created attachment 15663 [details]
Reproduction with workaround renderer
Comment 2 adrianknight89 2016-11-21 05:39:57 UTC
See https://github.com/xamarin/Xamarin.Forms/pull/554
Comment 3 Rui Marinho 2017-03-20 16:01:49 UTC
Should be fixed on 2.3.5-pre1

Note You need to log in before you can comment on or make changes to this bug.