UIImage
public extension UIImage
-
Creates an image based on a color.
Date
November 20, 2017Declaration
Swift
convenience init?(color: UIColor)
-
Creates a
UIImage
screenshot of the providedUIView
.Date
March 9, 2016Declaration
Swift
convenience init?(view: UIView, scale: CGFloat? = nil)
-
Creates a
UIImage
from a base64-encodedString
.Date
November 20, 2017Date
March 9, 2016Declaration
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 toself
.Date
February 17, 2016Declaration
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 specifiedCGRect
.Date
February 17, 2016Declaration
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 DocumentationEdited By: http://stackoverflow.com/a/8017292/39155
Date
February 17, 2016Declaration
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, 2016Declaration
Swift
func saveToFile(_ path: String, format: UIImageFormat) throws
-
Saves
self
to 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 }