How to set the backlight color of a system button applied to its image

If you create UIButtonand provide an image for it, for example

UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; [button setImage:[UIImage imageNamed:@"share"] forState:UIControlStateNormal];

The button image will be displayed as expected.

enter image description here

When you set enabledto NO, it automatically turns light gray:

enter image description here

Question: how to change the hue color used when the button is disabled? Instead, the default is light gray, I would like to apply a different gray color.

I know that if the button had text instead of an image, you could change the text color for the disabled state with [button setTitleColor:[UIColor darkGrayColor] forState:UIControlStateDisabled];, but since there is no name, just an image, I see no way to use a custom hue color for the disabled state.

, UIButtonTypeCustom, , . , , , , , - , , , . , , , , . .

+4

Source: https://habr.com/ru/post/1678144/


All Articles