UIImage

class UIImage : NSObject, NSSecureCoding
  • SwifterSwift: Size in bytes of UIImage

    Declaration

    Swift

    public var bytesSize: Int { get }
  • SwifterSwift: Size in kilo bytes of UIImage

    Declaration

    Swift

    public var kilobytesSize: Int { get }
  • SwifterSwift: UIImage with .alwaysOriginal rendering mode.

    Declaration

    Swift

    public var original: UIImage { get }
  • SwifterSwift: UIImage with .alwaysTemplate rendering mode.

    Declaration

    Swift

    public var template: UIImage { get }
  • SwifterSwift: Compressed UIImage from original UIImage.

    Declaration

    Swift

    public func compressed(quality: CGFloat = 0.5) -> UIImage?

    Parameters

    quality

    The quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality), (default is 0.5).

    Return Value

    optional UIImage (if applicable).

  • SwifterSwift: Compressed UIImage data from original UIImage.

    Declaration

    Swift

    public func compressedData(quality: CGFloat = 0.5) -> Data?

    Parameters

    quality

    The quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality), (default is 0.5).

    Return Value

    optional Data (if applicable).

  • SwifterSwift: UIImage Cropped to CGRect.

    Declaration

    Swift

    public func cropped(to rect: CGRect) -> UIImage

    Parameters

    rect

    CGRect to crop UIImage to.

    Return Value

    cropped UIImage

  • SwifterSwift: UIImage scaled to height with respect to aspect ratio.

    Declaration

    Swift

    public func scaled(toHeight: CGFloat, opaque: Bool = false, with orientation: UIImageOrientation? = nil) -> UIImage?

    Parameters

    toHeight

    new height.

    • opaque: flag indicating whether the bitmap is opaque.

    opaque

    flag indicating whether the bitmap is opaque.

    orientation

    optional UIImage orientation (default is nil).

    Return Value

    optional scaled UIImage (if applicable).

  • SwifterSwift: UIImage scaled to width with respect to aspect ratio.

    Declaration

    Swift

    public func scaled(toWidth: CGFloat, opaque: Bool = false, with orientation: UIImageOrientation? = nil) -> UIImage?

    Parameters

    toWidth

    new width.

    • opaque: flag indicating whether the bitmap is opaque.

    opaque

    flag indicating whether the bitmap is opaque.

    orientation

    optional UIImage orientation (default is nil).

    Return Value

    optional scaled UIImage (if applicable).

  • SwifterSwift: UIImage filled with color

    Declaration

    Swift

    public func filled(withColor color: UIColor) -> UIImage

    Parameters

    color

    color to fill image with.

    Return Value

    UIImage filled with given color.

  • SwifterSwift: UIImage tinted with color

    Declaration

    Swift

    public func tint(_ color: UIColor, blendMode: CGBlendMode) -> UIImage

    Parameters

    color

    color to tint image with.

    blendMode

    how to blend the tint

    Return Value

    UIImage tinted with given color.

  • SwifterSwift: UIImage with rounded corners

    Declaration

    Swift

    public func withRoundedCorners(radius: CGFloat? = nil) -> UIImage?

    Parameters

    radius

    corner radius (optional), resulting image will be round if unspecified

    Return Value

    UIImage with all corners rounded

  • SwifterSwift: Create UIImage from color and size.

    Declaration

    Swift

    public convenience init(color: UIColor, size: CGSize)

    Parameters

    color

    image fill color.

    size

    image size.