CATransform3DMakeRotation 和阴影
我正在创建翻转动画库。
简而言之,我创建了 CALayer 并使用 CoreAnimation 的 CATransform3DMakeRotation 旋转它。
问题是 - 有没有办法为该场景添加阴影?无需使用 OpenGL 重写整个代码:)
I'm creating the flip animation library.
In two words, I create the CALayer and 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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看
CAGradientLayer
。我目前正在使用它在类似的情况下添加阴影。可能在性能方面代价高昂(仍需检查),但看起来相当令人信服。
将
CAGradientLayer
作为子图层添加到图层中,并为其不透明度
设置动画。您可能需要稍微调整一下渐变停止点和颜色才能使其正确。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 itsopacity
. You may have to play around a little with the gradient stops and colors to get them right.我不确定
OpenGL
,但你检查过CATransform3D
添加到
.pch文件中,
你可以继续在这里改变角度
DEGREES_TO_RADIANS(90)
这里您可以向
myView
添加阴影。I am not sure about
OpenGL
but have you checkedCATransform3D
Add
in .pch file
you can go on changing the angle here
DEGREES_TO_RADIANS(90)
Here you can add shadow to
myView
.