Skip to content

Instantly share code, notes, and snippets.

@brownsoo
Created April 10, 2018 04:54
Show Gist options
  • Save brownsoo/24557db9277eace58b5a2aec25be975f to your computer and use it in GitHub Desktop.
Save brownsoo/24557db9277eace58b5a2aec25be975f to your computer and use it in GitHub Desktop.
tint color UIImage
public extension UIImage {
func tint(_ color: UIColor) -> UIImage {
let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
let renderer = UIGraphicsImageRenderer(size: rect.size)
let result = renderer.image { c in
color.setFill()
c.fill(rect)
self.draw(in: rect, blendMode: .destinationIn, alpha: 1)
}
return result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment