UIImage
public extension UIImage
-
Creates an image based on a color.
Date
November 20, 2017Declaration
Swift
convenience init?(color: UIColor) -
Creates a
UIImagescreenshot of the providedUIView.Date
March 9, 2016Declaration
Swift
convenience init?(view: UIView, scale: CGFloat? = nil) -
Creates a
UIImagefrom a base64-encodedString.Date
November 20, 2017Date
March 9, 2016Declaration
Swift
convenience init?(base64DataURLString: String?) -
Return a
UIImagewith the provided color blended into it.Date
February 17, 2016
Declaration
Swift
func image(withColor color: UIColor) -> UIImage?Parameters
colorThe color to blend into the image.
-
Return a
UIImagewith an alpha applied toself.Date
February 17, 2016Declaration
Swift
func image(withAlpha alpha: Float) -> UIImage?Parameters
alphaA float specifying the alpha level of the generated image.
Return Value
A
UIImagewith the alpha applied. -
Returns a
UIImagecropped to the dimensions of the specifiedCGRect.Date
February 17, 2016Declaration
Swift
func imageByCroppingToRect(_ rect: CGRect) -> UIImage?Parameters
rectthe
CGRectto crop the image to. -
Returns a screenshot of the current screen as a
UIImage.Note
Original Source: Apple Developer DocumentationEdited By: http://stackoverflow.com/a/8017292/39155
Date
February 17, 2016Declaration
Swift
class func screenshot() -> UIImage? -
Saves
selfto 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, 2016Declaration
Swift
func saveToFile(_ path: String, format: UIImageFormat) throws -
Saves
selfto the camera roll.Date
July 20, 2016Declaration
Swift
@available(iOS 9.0, *) func saveToCameraRoll(_ completion: ((Bool, NSError?) -> Void)?) throws -
The average color of
self.Date
May 24, 2017Declaration
Swift
var averageColor: UIColor? { get }
View on GitHub
UIImage Extension Reference