gpt4 book ai didi

uiview - 了解 CATransform3D

转载 作者:行者123 更新时间:2023-12-04 15:15:21 27 4
gpt4 key购买 nike

我正在 UIView 中使用 CATransform3DMakeRotation,并且我正在尝试进行 45º,变换就像向后放置一样:

http://cl.ly/2A2p1W1e2N3a1W181r35

这是我拥有的“代码”,但显然没有这样做。

CATransform3D _tr = CATransform3DMakeRotation(3.14/4, 1, 0, 0);
view.layer.transform = _tr;

请帮助我理解参数。
谢谢。

最佳答案

基本上,你的代码是正确的,但要获得透视效果,你需要设置sublayerTransform super View 的层是这样的:

CATransform3D perspectiveTransform = CATransform3DIdentity;
perspectiveTransform.m34 = 1.0 / -850;
myView.layer.sublayerTransform = perspectiveTransform;

您可以针对不同的失真量尝试不同的值。

关于uiview - 了解 CATransform3D,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6887786/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com