UIColor

This set of convenience initializers extends UIColor, providing easy ways to create color instances. The first initializer allows creating a color from a hexadecimal string representation with an optional alpha value. The second initializer creates a color from RGB values, and the third initializer adds the flexibility to specify a custom alpha value along with the RGB components. These initializers simplify the process of creating UIColor instances with various color representations.

  • Creates a UIColor instance from a hexadecimal string representation with an optional alpha value.

    Example:

      let hexColorString = "#FF5733"
      let color = UIColor(hexFromString: hexColorString, alpha: 0.8)
    
  • Creates a UIColor instance from RGB values.

    Example:

      let color = UIColor(red: 255, green: 87, blue: 51)
    
  • Creates a UIColor instance from RGB values with a specified alpha value.

    Example:

      let color = UIColor(red: 255, green: 87, blue: 51, reqAlpha: 0.8)