LoginSignup
16
16

More than 5 years have passed since last update.

[Swift]ColorManagerで色を一括管理

Posted at

開発環境

Xcode 7.2.1

作成方法

まず、新たなSwiftファイルをつくります。
AppDelegate_swift.png

作成したswiftにColorManager.swiftという名前を付けてあげます
スクリーンショット_2016_02_22_17_52.png

次に今つくったSwiftファイルにUIKitをインポートし、ColorManagerというクラスを作成します。
そして、それぞれ戻り値がUIColorという関数をそれぞれつくります。
以下の感じ!!

import UIKit

class ColorManager {
    func mainColor() -> UIColor {
        return UIColor(red: 30/255, green: 120/255, blue: 45/255, alpha: 1)
    }
}

ViewControllerなどで使いたいときは、こんな感じ

label.textColor = ColorManager().mainColor()
16
16
2

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
16
16