SCNBox中的CATextLayer以纵向模式显示

时间:2017-07-27 21:34:29

标签: ios calayer arkit catextlayer

我正在尝试将文本写入SCNBox节点。我看到框中的文字,但文字方向是肖像。我该如何制作这个风景?

screenshot

CALayer *layer = [CALayer new]; 
[layer setFrame:CGRectMake(0, 0, 100, 100)]; 
[layer setBackgroundColor:[UIColor redColor].CGColor];

CATextLayer *textLayer = [CATextLayer new];
[textLayer setFrame:[layer bounds]];
[textLayer setFontSize:24];
[textLayer setString:@"TEST"];
[textLayer setAlignmentMode:kCAAlignmentLeft];
[textLayer setForegroundColor:[UIColor blackColor].CGColor];
[textLayer display];
[layer addSublayer:textLayer];

SCNBox *box = [SCNBox boxWithWidth:1 height:2 length:0.005 chamferRadius:0.0];
[[[box firstMaterial] diffuse] setContents:layer];
// [[[box firstMaterial] diffuse] setContents:[UIColor redColor]]; 
[[box firstMaterial] setLightingModelName:SCNLightingModelConstant]; 
[[box firstMaterial] setDoubleSided:YES]; 
SCNNode *node = [SCNNode nodeWithGeometry:box];

1 个答案:

答案 0 :(得分:0)

您可以像这样旋转textLayer:

CGAffineTransform transform = CGAffineTransformIdentity;
transform = CGAffineTransformRotate(transform, self.angle);  // angle in radians
label.transform = transform;