I essentially want an enum of UIColor
s broken by which team would use them. The hope is that it could be accessed easily. Something like:
UIColor.Residential.white
or UIColor.Commercial.white
The difficulty has been finding something that works in both Swift and Objective-C. Trying all manner of @objc and @objMembers in front of the extension and class declarations has stumped me. Is there a pattern for this kind of thing?
Something like the below would be ideal.
extension UIColor {
@objc class Residential {
static let navbarBlue = UIColor.color(hexString: "003865")
}
@objc class Commercial {
static let navbarBlue = UIColor.color(hexString: "010101")
}
}
Right now, I'm using the below, and it's working fine, but I dislike the naming duplication.
extension UIColor {
@objc static let residentialDarkBlueNavBar = UIColor.color(hexString: "003865")
@objc static let commercialLightBlueNavBar = UIColor.color(hexString: "0B60BB")
@objc static let residentialBackgroundNavBar = UIColor.color(hexString: "0E49AD")
@objc static let commercialBackgroundGray = UIColor.color(hexString: "F2F2F6")
}
Edit
The other question I've been referenced to recommends calling class methods to calculate the colors from a hex. But these are static variables that do not need to be calculated when called. Yes, the performance hit is negligible, but I'd like to access organized static variables in both Swift and ObjC without calling a method each time. If that's not possible, I'll do what the other question says. I just want to know if it is.
Thanks!