iPhone: CALayer + rotate in 3D + antialias?

青春壹個敷衍的年華 提交于 2019-11-28 08:44:13

You could try adding some transparent pixels around the edge of the image, either by putting the UIImageView in a slightly larger empty view that you apply rotation to, or by changing the source images.

If you rotate only one image, than one trick will resolve the problem. Try to set

layer.shadowOpacity = 0.01;

After that picture will look smoother after 3D Rotation

The Gloomcore answer give a really neat result.

however this sometime make things really LAGGY ! Adding rasterization help a little bit:

.layer.shadowOpacity = 0.01;
.layer.shouldRasterize = YES;

I know the question/answer is old, but hey i just found it.

Raz

I had a similar issue that was solved by only setting shouldRasterize = YES, however because I was re-using my views (and layers), the shouldRasterize = YES killed the performance.

Fortunately I found a solution by turning shouldRasterize = NO at the right time to restore performance in my app's case.

I posted a solution here: Antialiasing edges of UIView after transformation using CALayer's transform

You can try this

Method: Using layer.shouldRasterize

  1. Create a superlayer/superview which is 1 pixel bigger in all 4 directions
  2. Do the transform on the superlayer/superview
  3. Enable layer.shouldRasterize on the original layer/view

Method: Drawing to a UIImage

  • Draw your content to a UIImage
  • Make sure that you have a transparent border of 1 pixel around the content
  • Display the image

Reference: http://darknoon.com/2012/05/18/the-transparent-border-trick/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!