Scaled Retina Images in CALayer

I have a UIView that fits as a preview in a UIScrollView. I have several child views consisting of images, text and buttons in a UIView. To get decent scroll performance, I set shouldRasterize = YES to a layer in a UIView. This did a great job in this performance, so I have a smooth scroll and no problem, since my graphics are static after drawing. However, the problem is that when I set shouldRasterize, the rasterized graphics are blurry and have a low resolution on the Retina display. Is there a way to have high resolution graphics that are rasterized for performance?

+48
ios iphone
Dec 17 '10 at 22:02
source share
2 answers

It seems I need to set the Scale rasterization to the correct value for the device as follows.

 myView.layer.rasterizationScale = [[UIScreen mainScreen] scale]; 
+119
Dec 17 '10 at 22:10
source share

I had a similar problem - a rotating UIView with multiple UIImageView subzones. When I set rasterizationScale = 2.0 , the images became sharper, but this led to a re-launch. To fix this, I created a containerView that contained UIView and UIImageView (which were previously discussed in UIView) and applied rasterizationScale = 1.0 to UIView and rasterizationScale = 2.0 to UIImageView s. Now everything looks good.

0
Apr 20 '12 at 19:32
source share



All Articles