How can I add stickers to an image in Swift?
Here's the easy way.
- have a
UIView
as a parent, let's saystickerView
- add image to
stickerView
- add stickers to
stickerView
- save a snapshot of
stickerView
Here's the code to snapshot UIView
,
extension UIImage {
class func imageWithView(view: UIView) -> UIImage {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0)
view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true)
let img = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return img
}
}
Usage
let snapshotImage = UIImage.imageWithView(stickerView)