Bug 25209 - [iOS] Buttons UIButtonType cannot be changed/specified or changed
Summary: [iOS] Buttons UIButtonType cannot be changed/specified or changed
Status: RESOLVED FEATURE
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.2.3
Hardware: PC Mac OS
: Normal enhancement
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-12-09 18:19 UTC by John Miller [MSFT]
Modified: 2015-05-26 04:37 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FEATURE

Description John Miller [MSFT] 2014-12-09 18:19:08 UTC
**Overview:**

   On iOS, the ButtonRenderer uses a UIButtonType.RoundedRect. It is desirable to be able to change this so that customizations can be done. For example, when trying to set a background images for state changes, UIButtonType.Custom should be used because RoundedRect has some built-in functionality that messes with this. 

e.g.

>var nativeButton = UIButton.FromType(UIButtonType.Custom);
>nativeButton.SetBackgroundImage(UIImage.FromBundle("greenButton.png").StretchableImage(12, 0), UIControlState.Normal);
>nativeButton.SetBackgroundImage(UIImage.FromBundle("greenButtonActivated.png").StretchableImage(12, 0), UIControlState.Highlighted);
>SetNativeControl(nativeButton);

The above code is an attempt to get the images working correctly. UIButtonType.Custom is needed because RoundedRect changes the opacity of the control when UIControlState.Highlighted is true, which is not what is wanted when specifying an image. Doing the above works, but now the other properties are not working - Clicked events, etc. 

An event can be manually added back in, but then the Command binding for the custom Button class is broken.

**Build Date & Platform:**

   XF 1.2.3

**Additional Information:**

   I have not found a suitable workaround to use UIButtonType.Custom and have all the default things still be in place like Clicked and bindings, etc.
Comment 1 Stephane Delcroix 2015-05-26 04:37:28 UTC
Thank you for your feature request, we will take your feedback into consideration.