🌟

プロトタイプ的にiOSアプリを作っていく場合の色の指定

2021/07/09に公開

概要

  • どういう状況
    • デザイナからの正式なデザインを反映する段階にない
      • アプリのプログラマがプロトタイプ的に作っていく段階
    • ダークモード対応を加味しておきたい
      • 自身がダークモードで使ってたりするため

Labelの色

優先して使うべき色は下記を使い、UIColor.blackUIColor.whiteは使わない。

    /* Foreground colors for static text and related elements.
     */
    @available(iOS 13.0, *)
    open class var label: UIColor { get }

    @available(iOS 13.0, *)
    open class var secondaryLabel: UIColor { get }

    @available(iOS 13.0, *)
    open class var tertiaryLabel: UIColor { get }

    @available(iOS 13.0, *)
    open class var quaternaryLabel: UIColor { get }   

これらはダークモードでは色が変わる。たとえばダークモードではlabelはwhiteになるし、ダークモードでなければlabelはblackになる。

button.setTitleColor(.label, for: .normal)

参考

https://developer.apple.com/videos/play/wwdc2019/214/

Discussion