RandomGeek
RandomGeek

Reputation: 333

Custom Color with cgColor

It might be the stupidest question you saw all day but i couldn't find a solution. i have a rounded image view with borders and i want the borders to be the the same blue as the default tint color in Xcode so if you could help that would be great . and sorry for the noonish question ;)

Now i have this:

self.imageView.layer.borderColor = UIColor.gray.cgColor

and i need to change

UIColor.gray.cgColor

to be the same blue as the default tint color without causing a crash or an error ... how can it be done?

thanks for your help.

Upvotes: 0

Views: 3697

Answers (2)

Suhit Patil
Suhit Patil

Reputation: 12023

just create the new color with blue color properties and apply to imageView

let color = UIColor(colorLiteralRed: 0, green: 122/255, blue: 1, alpha: 1.0)
self.imageView.layer.borderColor = color.cgColor

alertnatively you can use tintColor property of imageView like

imageView.layer.borderColor = imageView.tintColor.cgColor

Upvotes: 2

Val Nolav
Val Nolav

Reputation: 902

Just drag and drop whatever color you want such as: enter image description here

Upvotes: 2

Related Questions