UIImage

public extension UIImage
  • Creates an image based on a color.

    Date

    November 20, 2017

    Declaration

    Swift

    convenience init?(color: UIColor)
  • Creates a UIImage screenshot of the provided UIView.

    Date

    March 9, 2016

    Declaration

    Swift

    convenience init?(view: UIView, scale: CGFloat? = nil)
  • Creates a UIImage from a base64-encoded String.

    Date

    November 20, 2017

    Date

    March 9, 2016

    Declaration

    Swift

    convenience init?(base64DataURLString: String?)
  • Return a UIImage with the provided color blended into it.

    Date

    February 17, 2016

    Declaration

    Swift

    func image(withColor color: UIColor) -> UIImage?

    Parameters

    color

    The color to blend into the image.

  • Return a UIImage with an alpha applied to self.

    Date

    February 17, 2016

    Declaration

    Swift

    func image(withAlpha alpha: Float) -> UIImage?

    Parameters

    alpha

    A float specifying the alpha level of the generated image.

    Return Value

    A UIImage with the alpha applied.

  • Returns a UIImage cropped to the dimensions of the specified CGRect.

    Date

    February 17, 2016

    Declaration

    Swift

    func imageByCroppingToRect(_ rect: CGRect) -> UIImage?

    Parameters

    rect

    the CGRect to crop the image to.

  • Returns a screenshot of the current screen as a UIImage.

    Note

    Original Source: Apple Developer Documentation

    Edited By: http://stackoverflow.com/a/8017292/39155

    Date

    February 17, 2016

    Declaration

    Swift

    class func screenshot() -> UIImage?
  • Saves self to a file.

    image.saveToFile("image.png", format: .PNG)
    

    You can also specify a JPEG export, but you’ll need to specify the quality as well.

    image.saveToFile("image.jpg", format: .JPEG(0.9))
    

    Date

    July 20, 2016

    Declaration

    Swift

    func saveToFile(_ path: String, format: UIImageFormat) throws
  • Saves self to the camera roll.

    Date

    July 20, 2016

    Declaration

    Swift

    @available(iOS 9.0, *)
    func saveToCameraRoll(_ completion: ((Bool, NSError?) -> Void)?) throws
  • The average color of self.

    Date

    May 24, 2017

    Declaration

    Swift

    var averageColor: UIColor? { get }