iOS 13 UITextView converting UITextView to image is not working properly. Working fine in below iOS 12

后端 未结 5 1615
鱼传尺愫
鱼传尺愫 2020-12-10 07:28

How to solve this issue in iOS 13? I am taking screenshot of UITextView content size..Till iOS 12 everything is working fine. But issue with iOS 13 onwards it\'s not taking

5条回答
  •  感情败类
    2020-12-10 08:07

    Don't draw the layer, use the attributedText instead

    let size = self.textView.contentSize
    UIGraphicsBeginImageContextWithOptions(size, self.textView.isOpaque, 0)
    //the textView has 8 margin
    textView.attributedText.draw(in: CGRect.init(x: 0, y: 0, width: size.width - 16, height: size.height))
    let image = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    

提交回复
热议问题