How to Use " Let Newswiftcolor = Uicolor(Red: 255, Green: 165, Blue: 0, Alpha: 0)

How do you use let newSwiftColor = UIColor(red: 255, green: 165, blue: 0, alpha: 0)?

Since you're creating a new variable that contains a reference to a UIColor (newSwiftColor), it would just be:

calcbutton.layer.borderColor = newSwiftColor.CGColor

Note that Colors in UIKit are specified using floats from 0..1 not ints from 0..255, so you need to divide all your RGB values by 255.0:

let newSwiftColor = UIColor(red: 34.0/255.0, green: 167.0/255.0, blue: 239.0/255.0, alpha: 0)

Wrong color when convert UIColor to CGColor

Colors in UIKit are specified using value is between 0 and 1 in float not int from 0 to 255, so you need to divide all your RGB values by 255.0.

let color = UIColor(red: 198.0/255.0, green: 35.0/255.0, blue: 80.0/255.0, alpha: 1.0)


Related Topics



Leave a reply



Submit