Nazia Jan
Nazia Jan

Reputation: 783

UILabel TextColor Not Changing On iphone

I am changing a UILabels text color too the given code below, but it is not working.

    Q1.textColor=[UIColor colorWithRed:88/255.0 green:89/255.0 blue:91/255.0 alpha:0];

Upvotes: 0

Views: 1290

Answers (7)

npn
npn

Reputation: 113

Besides providing alpha value 0.0, Check for integer division vs float division as the method needs floats, so when you are dividing 88 (int) by a 255.0 (float) you are providing 0 instead of 0.34 for red value and similarly for green and blue.

Upvotes: 1

rhalgravez
rhalgravez

Reputation: 366

You need to change alpha to 1, Alpha represents opacity ( transparency).

Upvotes: 0

Hemang
Hemang

Reputation: 27050

    [Q1 setTextColor:[UIColor colorWithRed:88.0/255.0 green:89.0/255.0 blue:91.0/255.0 alpha:1.0]];

You just forget to add alpha:1.0 :)

Upvotes: 0

user529758
user529758

Reputation:

You probably wanted the alpha to be equal to 1 instead of 0 (zero means fully transparent, you might have misunderstood this...):

Q1.textColor = [UIColor colorWithRed:88 / 255.0f
                               green:89 / 255.0f
                                blue:91 / 255.0f
                               alpha:1.0f];

By the way, the title of your question is inaccurate. The text color is most probably changing, but you don't see the text since it's transparent.

Upvotes: 1

jturolla
jturolla

Reputation: 6746

Are you trying to make it transparent? You should try alpha 1.

Q1.textColor = [UIColor colorWithRed:88/255.0 green:89/255.0 blue:91/255.0 alpha:1];

Upvotes: 0

Sameera Chathuranga
Sameera Chathuranga

Reputation: 3666

 Q1.textColor=[UIColor colorWithRed:(88/255.f) green:(89/255.f) blue:(91/255.f) alpha:1];

Upvotes: 1

Paresh Navadiya
Paresh Navadiya

Reputation: 38239

Do this as your color alpha is 0 means transparent

   Q1.textColor=[UIColor colorWithRed:88.0/255.0 green:89.0/255.0 blue:91.0/255.0 alpha:1];

Upvotes: 0

Related Questions