SCNText对齐方式在iOS中不起作用 [英] SCNText Alignment not working in iOS

查看:52
本文介绍了SCNText对齐方式在iOS中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了右对齐,但是仍然保持左对齐.

I tried right alignment, but it's still left aligned.

let txt = SCNText(string: "TEST", extrusionDepth: 10) 
txt.chamferRadius = 5 //0<chamfer<extrusion depth
txt.firstMaterial.diffuse.contents  = UIColor.whiteColor() 
txt.containerFrame = CGRectMake(-200, -150, 400, 200) //on iPad Air Sim in Landscape
txt.wrapped = true
txt.alignmentMode = kCAAlignmentRight

怎么了?

谢谢!

推荐答案

对齐似乎可行-尝试在测试字符串中添加第二行,例如"TEST\nT",然后在左右对齐模式之间切换.但是SCNText可以适应其节点的坐标系,因此仅靠对齐并不一定会使文本适合您的场景.

It looks like alignment is working -- try adding a second line to your test string like "TEST\nT" and switching between left and right alignment modes. But SCNText adapts to fit the coordinate system of its node, so alignment alone won't necessarily make the text fit into your scene the way you want it to.

您可以使用节点的pivot属性来调整节点的内容如何适合其父空间.根据

You can tweak how a node's content fits into its parent space using the node's pivot property. Set it to a translation transform (SCNMatrix4MakeTranslation) based on the bounding box of your text and you can change the layout however you like.

这篇关于SCNText对齐方式在iOS中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆