我在图片视图中添加了贴纸。
所以我用以下来源保存了它。
imageView.addSubview(StickerView[0])
// Create the image context to draw in
UIGraphicsBeginImageContextWithOptions((imageView.bounds.size), false, 0)
// Get that context
let context = UIGraphicsGetCurrentContext()
// Draw the image view in the context
imageView.layer.render(in: context!)
// You may or may not need to repeat the above with the imageView's subviews
// Then you grab the "screenshot" of the context
let image = UIGraphicsGetImageFromCurrentImageContext()
// Be sure to end the context
UIGraphicsEndImageContext()
CustomPhotoAlbum.sharedInstance.save(image: image! )
好好保存。但是,也会保存图像两侧的黑色背景。我可以只保存除黑色背景外的部分图像吗?
这是一起保存的。我只想保存除此之外的图像部分。