Why is my UIButton.tintColor not working?

后端 未结 13 1072
长情又很酷
长情又很酷 2020-12-03 04:15

My build target is set for IOS5 which is where I understand UIButton.tintColor was introduced...

I have this in my viewDidLoad for the View Controller

13条回答
  •  失恋的感觉
    2020-12-03 04:43

    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];
    

提交回复
热议问题