Skip to content

Instantly share code, notes, and snippets.

@SaladDays831
Created February 18, 2020 20:40
Show Gist options
  • Save SaladDays831/7631fb7dabbf3255a3280e88789875c7 to your computer and use it in GitHub Desktop.
Save SaladDays831/7631fb7dabbf3255a3280e88789875c7 to your computer and use it in GitHub Desktop.
[Swift] Set 2 PDFs to one UIImageView (merge multiple vector assets)
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