color.hue

  • On iOS 10 or later, an extended range color space specifies the hue component and can have any value. โญ๏ธ

  • Values 0.0 ~ 1.0 are inside the sRGB color gamut.

  • On earlier versions of iOS, the hue is always 0.0 ~ 1.0. ๐Ÿ‘‰ UIKit

import  SwiftUI

extension Color {
    /// `color.hue` (0 ~ 1)
    public var hue: CGFloat {
        var hue: CGFloat = 0
        UIColor(self).getHue(
            &hue, 
            saturation: nil, 
            brightness: nil, 
            alpha: nil
        )
        return hue
    }
}

Last updated