I am currently working on an Image app where I can put a Text Sticker that made with a UIView. I Applied CATransform3D to change the Perspective of the UIView. When I change the Values, it works properly and changes the Perspective View of the UIView. But when I try to Save the Image It goes to it's default position.
Here is the Code Transformation
func transformation ()
{
var transform = CATransform3DIdentity;
transform.m34 = 1.0 / -200
transform = CATransform3DRotate(transform, CGFloat(sliderX.value), 0, 1, 0)
transform = CATransform3DRotate(transform, CGFloat(sliderY.value), 1, 0, 0)
textStickerView.currentlyEditingLabel.layer.transform = transform
}
Saving Function
var imgSize = CGSize(width: mainImageView.bounds.size.width, height: mainImageView.bounds.size.height)
UIGraphicsBeginImageContextWithOptions(imgSize, false, UIScreen.main.scale)
mainImageView.addSubview(textStickerView)
mainImageView.layer.render(in: UIGraphicsGetCurrentContext()!)
let rowImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()