Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change in Button text color not reflecting

I am facing a weird issue. I am changing the text color of my button when it is highlighted but visually no change at all.

[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [myButton setTitleColor:[UIColor colorWithRed:150.0 green:150.0 blue:150.0 alpha:1.0] forState:UIControlStateHighlighted]; 

Am I missing something?

like image 997
Abhinav Avatar asked May 21 '11 00:05

Abhinav


People also ask

How do I change the color of my text buttons?

Use a semi-colon to separate the different style elements in the HTML button tag. Type color: in the quotation marks after "style=". This element is used to change the text color in the button. You can place style elements in any order in the quotation markers after "style=".


1 Answers

try:

[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [myButton setTitleColor:[UIColor colorWithRed:150.0/256.0 green:150.0/256.0 blue:150.0/256.0 alpha:1.0] forState:UIControlStateHighlighted]; 

Color components are floats between 0.0 and 1.0 !

like image 66
Roki Avatar answered Sep 20 '22 17:09

Roki