Vector drawing for scalable UIScrollView

I have a scalable UIScrollView with some CATextLayer and simple CALayer in it. They work fine, but the problem is when they are enlarged, they become blurry. (Even if I redraw them)

What would be my ability to prevent my text from blurring as the view enlarged? Should I use another? include something in CATextLayer / CALayer ? Any idea is welcome;)

I use CALayer because, as stated in the documentation, CALayer lighter than UIViews , and I have hundreds of them. It currently runs smoothly. I tried with UIWebView , and my version of CALayer faster;)

Thanks in advance.

+6
iphone calayer uiscrollview
source share
1 answer

iOS rasterizes text before scaling occurs, so it's so blurry. You only need to fix one property of your CATextLayer, contentsScale, to get a higher quality rendering after scaling. Implement this UIScrollViewDelegate method:

 - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale { [CATransaction begin]; [CATransaction setValue:[NSNumber numberWithBool:YES] forKey:kCATransactionDisableActions]; uglyBlurryTextLayer.contentsScale = scale; [CATransaction commit]; } 

This says the layer uses more pixels to render the text and disables Core Animation when this particular change is made.

+16
source share

All Articles