Created
December 21, 2016 09:31
-
-
Save yickling/676942ff60abc969574c6a75f86ff04c to your computer and use it in GitHub Desktop.
Placeholder UIImage in Swift
This file contains 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
func generatePlaceholderImageWithColor(_ color: UIColor) -> UIImage? { | |
let rect : CGRect = CGRect(x: 0, y: 0, width: 1, height: 1) | |
UIGraphicsBeginImageContextWithOptions(rect.size, false, 0) | |
color.setFill() | |
UIRectFill(rect) | |
let image : UIImage = UIGraphicsGetImageFromCurrentImageContext()! | |
UIGraphicsEndImageContext() | |
return image | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment