How can I make a Swift enum with UIColor value? -


i'm making drawing app , refer colors through use of enum. example, cleaner , more convenient use colors.redcolor instead of typing out values every time want red color. however, swift's raw value enums don't seem accept uicolor type. there way enum or similar?

i (basically using struct namespace):

extension uicolor {   struct mytheme {     static var firstcolor: uicolor  { return uicolor(red: 1, green: 0, blue: 0, alpha: 1) }     static var secondcolor: uicolor { return uicolor(red: 0, green: 1, blue: 0, alpha: 1) }   } } 

and use like:

uicolor.mytheme.firstcolor 

so can have red color inside custom theme.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -