ios - Global Color Palette for Interface Builder -


in swift i'm writing extension (like obj-c category) maintains in code class methods of "house colors." i'm wondering if there way make color extension accessible interface builder using ibinspectable or else opposed attaching colors uiview subclasses i've seen in lot of ibinspector sample usage.

extension uicolor {     // house blue     @ibinspectable var houseblue: uicolor { return uicolor(red:(51/255), green:(205/255), blue:(255/255), alpha:(1)) }      // house gray     @ibinspectable var housegray: uicolor { return uicolor(white:0.4, alpha: 1) }      // house white     @ibinspectable var housewhite: uicolor { return uicolor.whitecolor() } } 

as far know, can't programatically define colors show in interface builder, can extend uicolor custom colors use in code:

extension uicolor {     static func mycustomcolor() -> uicolor {      return uicolor(red: 23/255.0, green: 175/255.0, blue: 72/255.0, alpha: 1.0)    }  } 

and reference custom color:

myview.backgroundcolor = uicolor.mycustomcolor() 

this doesn't solve issue, potentially better set colors programatically through ib. allow adjust value 1 time in code change color throughout app rather having adjust multiple times each ui element through interface builder.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -