Created
May 24, 2015 05:40
-
-
Save pala/60cd2aafd6e97fd1e961 to your computer and use it in GitHub Desktop.
UIImage extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://twitter.com/dwineman/status/601853359839006721 | |
// Default arguments are expressions, not constants, evaluated only when necessary. | |
extension UIImage { | |
static func emptyImage(size: CGSize, scale: CGFloat = UIScreen.mainScreen().scale) -> UIImage { | |
UIGraphicsBeginImageContextWithOptions(size, false, scale) | |
let image = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return image | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment