UIButton tint color for state support

Originator:bruno
Number:rdar://49639040 Date Originated:05/04/2019
Status:Open Resolved:
Product:iOS + SDK / UIKit Product Version:n/a
Classification:Suggestion Reproducible:n/a
 
UIButton would benefit greatly from proper support for different tint colors per UIControl state.

A very common design for buttons is a button with text and an image. UIButton provides the support for this with `image(for:)` and `setImage(for:)`. However, while it is possible to change the title color per state, it's not possible to change the image's tint color per state. If this were possible, it would enable designs where the image tint color follows the title color without having to resort to overriding all the state setters.

For example, one could make a button with a title, template image and background image as follows;

* Normal state: Orange background image, black title text and black icon.
* Disabled state: Gray background image, white title and white icon.

Currently, this requires to set separate images per state, instead of being able to rely on the tint color.

Proposed API:

```
open func UIButton.setTintColor(_ color: UIColor, for controlState: UIControl.State)
open func UIButton.tintColor(for controlState: UIControl.State) -> UIColor?
```

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!