Question

I'm displaying a UIView with a UILabel on it and this view&label become blurry as soon as it gets to these lines code:

CATransform3D transform = CATransform3DIdentity;      
transform.m34 = (1.0/-500);
view.layer.transform = transform;

Throughout the App I use CA3DRotations and other stuff and this never happened before. Also, I set the frame of the view and the label only using integers! So it's not a half-pixel problem or something like that, I know that that causes most blurry problems, but not mine!

On the simulator it's not blurry, iPad is not blurry, iPhone3GS is not blurry. Only on an iPhone4 with Retina display it becomes blurry. Even before I do any 3D rotations! Does anybody have a clue before I go insane?

Was it helpful?

Solution

Alright, I've found a solution. After using a hundred different lines of code using layer properties, such as layer gravity or magnification and tons of other solutions I suddenly stumbled by accident on the following 2 lines:

self.layer.shouldRasterize = TRUE;
self.layer.rasterizationScale = [[UIScreen mainScreen] scale];

This is the solution! For everyone in the future, is your view blurry on retina displays? Use this!

OTHER TIPS

Have you set the contentsScale for the layer to match [UIScreen mainScreen]. scale? Try it.

It's possible your views are 'between pixels' (eg. center is [12.5, 10]). Try rounding their location and see if that helps.

If your final landing position is intended to be flat/untransformed, simply setting the transform to CATransform3D identity will also fix the problem. Depending on how things are animated, setting a final position for one of the 3D transforms to 0.0 can still introduce rounding errors and give a fuzzy appearance.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top