fernandodelrio / SwiftColorGen

A tool that generate code for Swift projects, designed to improve the maintainability of UIColors
MIT License
150 stars 5 forks source link

Colors as Computed Properties #12

Closed Gatada closed 6 years ago

Gatada commented 6 years ago

I would prefer seeing the generated colours added as computed properties, as we are simply accessing a defined value of a particular type - and not doing any functional computation or state changing.

fernandodelrio commented 6 years ago

I like the idea. Something like:

extension UIColor {
    /// Color #FFC034 (alpha 255)
    static var myColor: UIColor {
        return UIColor(named: "MyColor") ?? .clear
    }
}

Accessing like:

UIColor.myColor

I will implement it 👍

fernandodelrio commented 6 years ago

Done on 0.5.1