You can merge two images using UIGraphicsBeginImageContext
. Here is a small function written with Swift 2.1.1 which takes two images and creates a single image.
func mergeImages (forgroundImage : UIImage, backgroundImage : UIImage) {
let bottomImage = forgroundImage
let topImage = backgroundImage
let size = backgroundImage.size
UIGraphicsBeginImageContext(size)
let areaSize = CGRect(x: 0, y: 0, width: size.width, height: size.height)
bottomImage.drawInRect(areaSize)
topImage.drawInRect(areaSize, blendMode: .Normal, alpha: 1.0)
let newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext()
resultImageView.image = newImage
UIGraphicsEndImageContext()
}
You can call it like
mergeImages(yourImageViewOne.image!, backgroundImage: yourImageViewTwo.image!) // Call to mege images
And here is a link for further exploring.