Created
February 18, 2020 20:40
-
-
Save SaladDays831/7631fb7dabbf3255a3280e88789875c7 to your computer and use it in GitHub Desktop.
[Swift] Set 2 PDFs to one UIImageView (merge multiple vector assets)
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 UIImageView { | |
func mergeTwoPDF(one: UIImage, two: UIImage) { | |
UIGraphicsBeginImageContextWithOptions(self.frame.size, false, UIScreen.main.scale) | |
let areaSize = CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height) | |
one.draw(in: areaSize, blendMode: .normal, alpha: 1.0) | |
two.draw(in: areaSize, blendMode: .normal, alpha: 1.0) | |
//If you want to merge more than 2 images, just add them to the func parameters and repeat the line above with them | |
let mergedImage = UIGraphicsGetImageFromCurrentImageContext()! | |
UIGraphicsEndImageContext() | |
self.image = mergedImage | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment