i'm creating app shows how many likes/dislikes user has on videos. like/dislike text have 0.5 alpha. how code looks like
my code looks this, question how make "likes/dislikes" text have 0.5 alpha ?
self.ratinglabel.text = @"%i likes %i dislikes", likes, dislikes;
first of create color 0.5 alpha component, form existing color:
uicolor* color= [somecolor colorwithalphacomponent: 0.5];
or scratch:
uicolor* color= [uicolor colorwithred: red green: green blue: blue alpha: 0.5];
then have create attributed string , set attributedtext of label. attribute foreground color nsforegroundcolorattributename:
nsstring* text= [nsstring stringwithformat: @"%i likes %i dislikes", likes, dislikes]; self.ratinglabel.attributedtext= [[nsattributedstring alloc]initwithstring: text attributes: @{ nsforegroundcolorattributename : color}];
Comments
Post a Comment