0

According to this answer:

Bordered UITextView

I can use premixed colors like blackColor, blueColor etc...

I want to use my own color though, made from UIColor colorWithRed: ...

ratingText.layer.borderColor = [[UIColor colorWithRed:33 green:95 blue:139 alpha:1] CGColor];

The border then is not displayed. How could I bridge the UIColor to CGColor, or do I miss anything else?

Help is greatly appreciated - thx!

Community
  • 1
  • 1
coernel
  • 79
  • 1
  • 9

1 Answers1

0

[UIColor colorWithRed:green:blue:alpha:] takes float value from 0 to 1. Values greater than 1 will consider as 1. Therefore this will result in white color.

You should first convert the rgb value(0-255) to float value(0-1) first by dividing 255.

layer.borderColor = [[UIColor colorWithRed:33/255.0f green:95/255.0f blue:139/255.0f alpha:1] CGColor];
Hanon
  • 3,917
  • 2
  • 25
  • 29