Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
let scaledImage: UIImage
do {
UIGraphicsBeginImageContextWithOptions(size, false, 0.0)
defer {
UIGraphicsEndImageContext()
}
// Fill background
UIColor.blackColor().setFill(); UIRectFill(CGRect(origin: .zero, size: size))
// Draw scaled image
let drawingRect: CGRect = CGRect(
origin: drawingOrigin,
size: CGSize(width: scaledWidth, height: scaledHeight))
image.drawInRect(drawingRect)
// Fetch image
scaledImage = UIGraphicsGetImageFromCurrentImageContext()!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.