CATransform3DMakeRotation and shadow
I'm creating the flip animation library.
In two words, I create the CALayer a开发者_StackOverflow社区nd rotate it using CoreAnimation's CATransform3DMakeRotation.
The question is – is there a way to add a shadow to that scene? Without rewriting the whole code with OpenGL :)
Have a look at CAGradientLayer
. I am currently using it to add shadows in a similar situation. May be costly performance-wise (still have to check that), but looks quite convincing.
Add CAGradientLayer
as sublayer(s) to your layers and animate its opacity
. You may have to play around a little with the gradient stops and colors to get them right.
I am not sure about OpenGL
but have you checked CATransform3D
Add
#define DEGREES_TO_RADIANS(d) (d * M_PI / 180)
in .pch file
CATransform3D myTransform = CATransform3DIdentity;
myTransform.m34 = 1.0 / -500;
myTransform = CATransform3DRotate(myTransform, DEGREES_TO_RADIANS(90), 0.0f, 0.0f, 1.0f);
myView.layer.transform = myTransform;
you can go on changing the angle here DEGREES_TO_RADIANS(90)
Here you can add shadow to myView
.
精彩评论