mono0926
9/25/2016 - 12:08 AM

UIColor+extensions.swift

import UIKit

extension UIColor {
    class var theme: UIColor { return #colorLiteral(red: 0.4274509804, green: 0.7568627451, blue: 0.6196078431, alpha: 1) }
    
    // 別解1(推奨)
    struct MyApp {
        static var theme: UIColor { return #colorLiteral(red: 0.4274509804, green: 0.7568627451, blue: 0.6196078431, alpha: 1) }
    }
    
    // 別解2(Objective-Cチック)
    class var myapp_theme: UIColor { return #colorLiteral(red: 0.4274509804, green: 0.7568627451, blue: 0.6196078431, alpha: 1) }
}

// 別解1の利用例
let c = UIColor.MyApp.theme