标签: catransform3drotate

CATransform3DMakeRotation在动画期间隐藏了UIView的一半

使用带有CATransform3DMakeRotation的以下UIView动画,UIView的一半将在变换期间消失并在完成时重新出现.这只发生在界面构建器的视图层次结构中UIView后面的UIImageView时.

[UIView animateWithDuration:1.0 delay:0.0 options:nil animations:^{
        myView.layer.transform = CATransform3DMakeRotation(M_PI,0.0,1.0,0.0);
    } completion:nil];
Run Code Online (Sandbox Code Playgroud)

以下是界面构建器中的视图布局

Interface Builder布局

以及下面的动画结果.

在此输入图像描述

第二张图像是在任何动画发生之前,左半部分消失.收缩后,经过中心点后,右侧(前一个左侧)重新出现,如第四张图所示.

使用时设置背景图像

self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"jeans.png"]];
Run Code Online (Sandbox Code Playgroud)

动画按预期完成.

xcode core-animation interface-builder ios catransform3drotate

11
推荐指数
1
解决办法
1689
查看次数

CATransform3D:透视变换后计算高度

我有一个高度为50的图层,我将它围绕x轴旋转...如何在旋转进行时计算高度?

CATransform3D subLayerTransform = CATransform3DMakeTranslation(0, 0, 0);
subLayerTransform.m34 = -1 / 1800; //How does height relate to perspective and angle?
subLayerTransform = CATransform3DTranslate(subLayerTransform, 0, 0, 0);
subLayerTransform = CATransform3DRotate(subLayerTransform, 45 * (M_PI / 180), 1, 0, 0);
_transitionLayer.sublayerTransform = subLayerTransform;
Run Code Online (Sandbox Code Playgroud)

core-animation objective-c catransform3d ios catransform3drotate

5
推荐指数
1
解决办法
987
查看次数

使用CATransform3DMakeRotation时没有观点

我正在尝试使用UIView层执行3D旋转CATransform3DMakeRotation.我很困惑为什么这个简单的例子没有显示透视图,但看起来却被挤压了.我可以在使用时让旋转工作CATransform3DRotate,但我不想旋转,我想旋转到.谢谢.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    UIView *newView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    [newView setBackgroundColor:[UIColor orangeColor]];
    UILabel *newLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 50, 20)];
    [newLabel setText:@"Hello"];
    [newView addSubview:newLabel];
    [self.window addSubview:newView];

    CALayer *layer = newView.layer;

    CATransform3D perspective = CATransform3DMakeRotation(1.0, 0, 1, 0);
    perspective.m34 = -1 / 500;

    layer.anchorPoint = CGPointMake(1.0, 0.5);
    layer.zPosition = 99;
    layer.transform = perspective;

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
} …
Run Code Online (Sandbox Code Playgroud)

iphone core-animation objective-c ios catransform3drotate

2
推荐指数
1
解决办法
2088
查看次数