Color.rgb()

import SwiftUI

extension Color {
    /// usage: `Color.rgb(9, 73, 109)`
    /// - alpha (opacity): 0 ~ 1
    static func rgb(_ r: Double, _ g: Double, _ b: Double, _ a: Double = 1) -> Color {
        Color(red: r/255, green: g/255, blue: b/255, opacity: a)
    }
}

// custom colors
let darkCerulean = Color.rgb(9, 73, 109)    // dark blue
let pacificBlue = Color.rgb(0, 146, 219)    // light blue

Last updated