UIImage

Extends UIImage to support the Action Data controls and adds convenience methods for working with image properties in a Codable, Encodable or Decodable class.

Examples:

// Assign aa image from Base 64 encoded String in iOS, tvOS or watchOS
let imageString = UIImage(named: "Background.png").toString()
let image: UIImage ~= imageString
  • Defines the Image Representation Format that will be used when converting a UIImage to String (via toString()) or to Data (via toData()).

    See more

    Declaration

    Swift

    public enum ImageRepresentationFormat
  • Sets the UIImage from the given Base 64 encoded String instance.

    Examples:

    // Assign an image from Base 64 encoded String in iOS, tvOS or watchOS
    let imageString = UIImage(named: "Background.png").toString()
    let image: UIImage ~= imageString
    

    Declaration

    Swift

    public static func ~= ( left: inout UIImage, right: String)
  • Sets the UIImage from the given Data instance.

    Examples:

    // Assign an image from Base 64 encoded Data in iOS, tvOS or watchOS
    let imageData = UIImage(named: "Background.png").toData()
    let image: UIImage ~= imageData
    

    Declaration

    Swift

    public static func ~= ( left: inout UIImage, right: Data)
  • Converts the UIImage to a String representation encoded in Base 64.

    Examples:

    // Assign an image to Base 64 encoded String in iOS, tvOS or watchOS
    let imageString = UIImage(named: "Background.png").toString()
    

    Declaration

    Swift

    public func toString(imageRepresentation: ImageRepresentationFormat = .pngRepresentation) -> String

    Parameters

    imageRepresentation

    Determines the representation that will be used when converting the image. The default is pngRepresentation.

    Return Value

    The UIImage in the requested representation converted to a Base 64 encoded string.

  • Converts the UIImage to a Data representation.

    Examples:

    // Assign an image to Base 64 encoded Data in iOS, tvOS or watchOS
    let imageData = UIImage(named: "Background.png").toString()
    

    Declaration

    Swift

    public func toData(imageRepresentation: ImageRepresentationFormat = .pngRepresentation) -> Data?

    Parameters

    imageRepresentation

    Determins the representation that will be used when converting the image. The default is pngRepresentation.

    Return Value

    The UIImage in the requested representation converted to a raw Data.

  • Creates a new UIImage instance from a Base 64 encoded string.

    Examples:

    // Assign an image from Base 64 encoded String in iOS, tvOS or watchOS
    let imageString = UIImage(named: "Background.png")
    let image = UIImage(fromString: imageString)
    

    Declaration

    Swift

    public convenience init?(fromString value: String)

    Parameters

    value

    A Base 64 encoded String representing an image.