I'm trying to reduce the quality of a message before its being sent, for example if the connect is poor I want to blur out the text in the UITextView
and if connection improves or internet comes back, then remove the blur and show the normal text in the UITextView
. I have tried using CATextLayer
doesn't work. Is there a way I can achieve this?
cell.messageTextView.text = theText
let textLayer = CATextLayer()
textLayer.string = cell.messageTextView.text
textLayer.contentsScale = 0.2
cell.messageTextView.layer.addSublayer(textLayer)
You can drop the quality of the layer by making it rasterized and reducing the scale of it:
let badQualityRatio: CGFloat = 4
textView.layer.shouldRasterize = true
textView.layer.rasterizationScale = UIScreen.main.scale/badQualityRatio
you can set the rasterizationScale
any number between 0 and UIScreen.main.scale