iPhone使CALayer倾斜 [英] iPhone skew a CALayer
本文介绍了iPhone使CALayer倾斜的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是一个初学者,我正在做一些练习以使自己熟悉CALayer ...
I'm a beginner and I am doing some exercises to familiarize myself with CALayer ...
我只是想知道如何倾斜(或倾斜) )的CALayer 45°角?
I just want to know how to "incline" (or skew) a CALayer 45° angle ?
谢谢。
推荐答案
您可以执行此操作,但必须弄乱层
的 transform
属性,即 struct CATransform3D
。您将需要做一些矢量数学操作。请参阅
You could do this but you would have to mess with the layer
's transform
property, which is a struct CATransform3D
. You're going to have to do some vector math to do this, as you . See the compute_transform_matrix(...)
function from this answer for more details.
您需要执行以下操作:
CGRect r = layer.bounds;
layer.transform = compute_transform_matrix(r.origin.x, r.origin.y, r.size.width, r.size.height,
r.size.height, r.origin.y, r.size.width + r.size.height, r.origin.y,
r.origin.x, r.origin.y + r.size.height, r.size.width, r.origin.y );
检查我的数学。应该是对的。
Check my math on this. It should be right.
这篇关于iPhone使CALayer倾斜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文