LoginSignup
2
0

More than 5 years have passed since last update.

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

Posted at

はじめに

コピペ用のメモ書き。

動作環境

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
        }
    }
}
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0