Posted at

定義済みUIColorを単純にStringで取り扱うため定義したenumのメモ

More than 1 year has passed since last update.


はじめに

コピペ用のメモ書き。


動作環境

Xcode 9.4.1

Swift 4.1


ソースコード


DefaultUIColor.swift


public enum DefaultUIColor: String {
case black
case darkGray
case lightGray
case white
case gray
case red
case green
case blue
case cyan
case yellow
case magenta
case orange
case purple
case brown
case clear

public func getUIColor() -> UIColor {
switch self {
case .black: return UIColor.black
case .darkGray: return UIColor.darkGray
case .lightGray: return UIColor.lightGray
case .white: return UIColor.white
case .gray: return UIColor.gray
case .red: return UIColor.red
case .green: return UIColor.green
case .blue: return UIColor.blue
case .cyan: return UIColor.cyan
case .yellow: return UIColor.yellow
case .magenta: return UIColor.magenta
case .orange: return UIColor.orange
case .purple: return UIColor.purple
case .brown: return UIColor.brown
case .clear: return UIColor.clear
}
}
}