Entitize
Entitize

Reputation: 4969

ios8 Swift - Converting UIColor

Is there any way to convert a UIColor to a string? For example,

var color = UIColor.purpleColor()
var colorString : String = //Purple

If you can help me it would be greatly appreciated. Thanks

Upvotes: 1

Views: 112

Answers (1)

Ashish Kakkad
Ashish Kakkad

Reputation: 23882

You can get color description

var color = UIColor.purpleColor()
var colorString : String = color.description
println(colorString)

var cgColorRef = UIColor.purpleColor().CGColor
var strColor = CIColor(CGColor: cgColorRef).stringRepresentation()
println(strColor)

Reference from : How to convert UIColor value to a named color string?

Upvotes: 2

Related Questions