Skip to content

Instantly share code, notes, and snippets.

@NikKovIos
Last active September 16, 2019 07:37
Show Gist options
  • Save NikKovIos/d5b4bf30cb7f0a5bb765191f74d55fd8 to your computer and use it in GitHub Desktop.
Save NikKovIos/d5b4bf30cb7f0a5bb765191f74d55fd8 to your computer and use it in GitHub Desktop.
Extension to make an image from UIColor
extension UIImage {
class func image(color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) -> UIImage {
return UIGraphicsImageRenderer(size: size).image { rendererContext in
color.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