Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS text rendering after zoom-in

I wrote a function to zoom in a UIView using CGAffineTransformScale. After a 2x zoom-in, all text looks really blurred. Images are OK if they are in higher resolution to begin with. Is there a way to re-render all text in proper resolution after zoom in?

Edit: I found a partial solution to my problem: http://markpospesel.wordpress.com/2012/04/03/on-the-importance-of-setting-contentscalefactor-in-catiledlayer-backed-views/

  • (void)didMoveToWindow { self.contentScaleFactor = 2.0; }

By adding the method above in a UIView category, UILabel, UIButton and most other views now render at high resolution. However, this does not affect UITextView or UIWebView. Text within any of these two views are still fuzzy.

So the new question is, how can a UITextView or UIWebView be redrawn at high resolution after zoom-in?

like image 411
Weichen Wang Avatar asked Jun 26 '12 00:06

Weichen Wang


1 Answers

Yes. You can set the contentScaleFactor on your UIView to cause it to render its backing view at a higher resolution. Careful on retina devices, though; you want to ensure your new contentScaleFactor is at least your [[UIScreen mainScreen] scale] . (I would set this before your animation so it is smooth.)

Edit: to be clear, you probably need to set the contentScaleFactor of the text view itself to [[UIScreen mainScreen] scale] * 2 in your 2x zoom example.

like image 189
Jesse Rusak Avatar answered Nov 09 '22 08:11

Jesse Rusak