I am writing an app where a button has a border with the hex color of #22A7EF. In the viewDidLoad section, I tried to set the colors of the borders like this:
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)