Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone: CALayer + rotate in 3D + antialias?

An iPhone SDK question: I'm drawing a UIImageView on the screen. I've rotated it in 3D and provided a bit of perspective, so the image looks like it's pointing into the screen at an angle. That all works fine. Now the problem is the edges of the resulting picture don't seem to be antialiased at all. Anybody know how to make it so?

Essentially, I'm implementing my own version of CoverFlow (yeah yeah, design patent blah blah) using quartz 3d transformations to do everything. It works fine, except that each cover isn't antialiased, and Apples version is.

I've tried messing around with the edgeAntialisingMask of the CALayer, but that didn't help - the defaults are that every edge should be antialiased...

thanks!

like image 780
Colin Avatar asked Apr 21 '10 19:04

Colin


3 Answers

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

like image 90
Gloomcore Avatar answered Sep 21 '22 09:09

Gloomcore


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.

like image 20
Lifely Avatar answered Sep 20 '22 09:09

Lifely


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.

like image 37
drawnonward Avatar answered Sep 22 '22 09:09

drawnonward