How to I properly set UIColor from int?

后端 未结 6 855
余生分开走
余生分开走 2021-01-05 11:47

I am trying to set the textColor of a UITextView by assigning it a value.

Earlier in the program I have

textView.textColor         


        
6条回答
  •  清酒与你
    2021-01-05 11:55

    as par you submited answer this is not an answer UIColorFromRGB is a Macro that define above at @implementation like

    #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0];
    

    Then you can use like

    textView.textColor = UIColorFromRGB(0x888888);
    

    you can use its property of UIColor for setting color of text bg-color etc in objective c

    enter image description here

提交回复
热议问题