Why is my UIButton.tintColor not working?

According to the documentation:

This property is not valid for all button types.

You need to switch your buttonType to another one of these. (Unfortunately, the documentation does not specify which specific button types support this property.)


As stated in other answers tint does not work for Custom Button types. Make sure you explicitly declare the button type. Do not just use [UIButton alloc] init]

This will work:

UIButton *mybutton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[mybutton setImage:[UIImage imageNamed:@"myImage"] forState:UIControlStateNormal];
mybutton.tintColor = [ODTheme blueTintColor];

Make sure your button "type" is set to System. If it is set to Custom it could be the reason the color of your button isn't changing. This is what happened to me and changing the type to System fixed it.


It tint your highlighted State color. When you tap/click on the UIButton the color specified with tintColor appears as long as you hold the tap/click on the UIButton.

resetButton.tintColor = [UIColor colorWithRed:0.764 green:1.000 blue:0.000 alpha:1.000];

The button is white in normal state. But if I tap on the button the color turns red, but only then.

IF you need to change the button so it looks like a red or blue one in the UIControlStateNormal then

Change the UIButtonType to UIButtonTypeCustom in Interface Builder or programmatically with

 UIButton *resetButton = [UIButton buttonWithType:UIButtonTypeCustom];

Change the attributes on your own and recreate the rounded corners

resetButton.backgroundColor = [UIColor redColor];
resetButton.layer.borderColor = [UIColor blackColor].CGColor;
resetButton.layer.borderWidth = 0.5f;
resetButton.layer.cornerRadius = 10.0f;

Tags:

Ios

Uibutton