gpt4 book ai didi

ios - 在 2D 中旋转 UIView,而不是 3D

转载 作者:行者123 更新时间:2023-11-29 10:56:33 25 4
gpt4 key购买 nike

当我使用以下任一代码时,按钮会以 3D 方式而不是 2D 方式(平贴屏幕)旋转。如何避免 3D 行为?这是按钮在旋转期间的样子:

enter image description here

CGAffineTransform rotationTransform = CGAffineTransformIdentity;
rotationTransform = CGAffineTransformRotate(rotationTransform, (offset/(180.0 * M_PI)));
button.transform = rotationTransform;

.

    button.transform = CGAffineTransformRotate(CGAffineTransformIdentity, (offset/(180.0 * M_PI)));

.

button.transform = CGAffineTransformMakeRotation(offset/(180.0 * M_PI));

最佳答案

这是一位 Apple 员工的回答:

When you set a transform the frame becomes less well-defined, to the point that you should no longer use it to size or position a view. Try using the center property instead, your probably not getting a 3D rotation, but a distortion due to the compounding effect of setting the frame and trnsform.

关于ios - 在 2D 中旋转 UIView,而不是 3D,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18009177/

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