Last active
May 7, 2021 04:28
-
-
Save NikhilManapure/7c154c92f56cb40a34335d8bd6fc896a to your computer and use it in GitHub Desktop.
Extension of UIImage to give overlay to an image.
This file contains hidden or 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 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