Last active
November 18, 2020 03:00
-
-
Save Andy0570/a247a00d223c356eeb8e02f281bdae09 to your computer and use it in GitHub Desktop.
通过颜色生成图片
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
extension UIColor { | |
func image(_ size: CGSize = CGSize(width: 1, height: 1)) -> UIImage { | |
return UIGraphicsImageRenderer(size: size).image { (rendererContext) in | |
self.setFill() | |
rendererContext.fill(CGRect(origin: .zero, size: size)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: