Skip to content

Instantly share code, notes, and snippets.

@NikhilManapure
Last active May 7, 2021 04:28
Show Gist options
  • Select an option

  • Save NikhilManapure/7c154c92f56cb40a34335d8bd6fc896a to your computer and use it in GitHub Desktop.

Select an option

Save NikhilManapure/7c154c92f56cb40a34335d8bd6fc896a to your computer and use it in GitHub Desktop.
Extension of UIImage to give overlay to an image.
extension UIImage {
func overlayed(with overlay: UIImage) -> UIImage? {
defer {
UIGraphicsEndImageContext()
}
UIGraphicsBeginImageContextWithOptions(size, false, scale)
self.draw(in: CGRect(origin: .zero, size: size))
overlay.draw(in: CGRect(origin: .zero, size: size))
if let image = UIGraphicsGetImageFromCurrentImageContext() {
return image
}
return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment