gpt4 book ai didi

iphone - UIView 的简单核心动画 3D 变换

转载 作者:技术小花猫 更新时间:2023-10-29 10:31:22 25 4
gpt4 key购买 nike

我正在尝试使用 CA 制作简单的部分翻转动画,但我在透视方面遇到了问题。我试过:

    [UIView animateWithDuration:1.0 animations:^{
self.someView.layer.anchorPoint = CGPointMake(0.5, 0);
self.someView.layer.transform = CATransform3DMakeRotation(M_PI*0.6,1.0,0.0,0.0);
} completion:^(BOOL finished){
// code to be executed when flip is completed
}];

如何获得这种良好的视角?

enter image description here

最佳答案

像这样的事情会做:

CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -1000.0;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, M_PI * 0.6, 1.0f, 0.0f, 0.0f);
[UIView animateWithDuration:1.0 animations:^{
self.someView.layer.anchorPoint = CGPointMake(0.5, 0);
self.someView.layer.transform = rotationAndPerspectiveTransform;
} completion:^(BOOL finished){
// code to be executed when flip is completed
}];

关于iphone - UIView 的简单核心动画 3D 变换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15374215/

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