Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIImageView gets blurry after layer transformation

I have a UIImageView add to a UIView as a subview. When I apply a transformation on the UIView's layer the UIImageView gets blurry. Why is that? How can this problem be resolved?

view.layer.position = newPosition;

I apply only this transformation.


Edit: I've tested it and if I apply other transformations like these:

view.layer.transform = newTransform;
view.layer.zPosition = newZPosition;

then the blurry doesn't appear, only if I change the layer position.

like image 986
Infinite Possibilities Avatar asked Dec 21 '22 22:12

Infinite Possibilities


2 Answers

Use

blurryDialog.frame = CGRectIntegral(blurryDialog.frame);

To set the frame coordinates to integer values

like image 73
slf Avatar answered Dec 26 '22 11:12

slf


I found the answer. When you set the position of a layer or a view then the origin of it can be float values and this causes the blurry thing. So the solution is to set also the frame's origin after you set the position. You just have to set the frame's position to integer values. On the UI this change won't be seen, but the image will not be blurry.

like image 23
Infinite Possibilities Avatar answered Dec 26 '22 11:12

Infinite Possibilities