Skip to content

Latest commit

History

History
130 lines (91 loc) 路 1.96 KB

File metadata and controls

130 lines (91 loc) 路 1.96 KB

EXTENSION

Color

public extension Color

Properties

inverted

var inverted: Color

Inverse color

Methods

hex(_:alpha:)

static func hex(_ hex: UInt, alpha: Double = 1) -> Self

Initialize with HEX

  • Parameter hex: HEX UInt value
  • Returns: Color

Parameters

Name Description
hex HEX UInt value

hex(_:alpha:)

static func hex(_ hex: String, alpha: CGFloat = 1) -> Self

Initialize with HEX

  • Parameter hex: HEX String value
  • Returns: Color

Parameters

Name Description
hex HEX String value

init(hex:)

init(hex: String)

Initialize with HEX

  • Parameter hex: HEX

Parameters

Name Description
hex HEX

random(opacity:)

static func random(opacity: CGFloat = 1.0) -> Color

Generate a random color

  • Parameter opacity: opacity
  • Returns: New color

Parameters

Name Description
opacity opacity

lighten(by:)

func lighten(by percentage: CGFloat = 30.0) -> Color

Lighten color

  • Parameter percentage: percentage (1 -100), default: 30
  • Returns: new color

Parameters

Name Description
percentage percentage (1 -100), default: 30

darken(by:)

func darken(by percentage: CGFloat = 30.0) -> Color

Darken color

  • Parameter percentage: percentage (1 -100), default: 30
  • Returns: new color

Parameters

Name Description
percentage percentage (1 -100), default: 30

dynamicColor(light:dark:)

static func dynamicColor(light: UIColor, dark: UIColor) -> Color

Create a color with a dark and light mode UIColor

  • Parameters:
    • light: light color
    • dark: dark color
  • Returns: Color

Parameters

Name Description
light light color
dark dark color