Thanks, @Claude for ur reply. but it is a different case. According to his issue, he needs to adjust the UILabel length after zoom it. Looks font is not blurring in that issue.
But he has point like
messageLabel.contentScaleFactor=scale;
is used for avoid to font blurring.
But i also use it like
uiTextView.contentScaleFactor = scale
it is not working for me. font is still blurring.
So I'm seeking a way of using UIScrollView and without redraw the objects (using default zoom in functionality).
Hopefully, someone can help me !!!!
Post
Replies
Boosts
Views
Activity
Hey Guys,
Finally, I was able to fix the font blurring issue successfully.
We have to consider scale factor both UITextView and CALayer of the UIView.
We need to update scale factor subviews as well using recursion.
func scaleView( view: UIView, scale: CGFloat ){
view.contentScaleFactor = scale
for vi in view.subviews {
scaleView(view: vi, scale: scale)
}
}
func scaleLayer( layer: CALayer, scale: CGFloat ){
layer.contentsScale = scale
if layer.sublayers == nil {
return
}
for la in layer.sublayers! {
scaleLayer(layer: la, scale: scale)
}
}
We should call the above two methods for UITextView in scrollViewDidEndZooming (which is inherited from UIScrollViewDelegate) method.
func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) {
scaleView(view: textView, scale: scale)
scaleLayer(layer: textView.layer, scale: scale)
}
But for the zoom-out feature, please don't set scale value directly then quality will lose. So need to keep the threshold value,it should be calculated according to your usage.