使用SCNText的alignmentMode选项很有趣。我在谷歌上搜索了一下,发现alignmentMode和containerFrame存在问题。我找到的替代方案建议使用get bounding box函数查找文本大小,然后手动进行调整。这很棒,但我无法使该函数正常工作。当我尝试获取两个向量时,出现错误:
“SCNVector3”无法转换为“UnsafeMutablePointer < SCNVector3>”
我在几何体和节点上都遇到了这个问题。以下是代码示例。
func setCounterValue(counterValue:Int) {
var v1 = SCNVector3(x: 0,y: 0,z: 0)
var v2 = SCNVector3(x: 0,y: 0,z: 0)
_counterValue = counterValue
let newText = SCNText(string: String(format: "%06d", counterValue), extrusionDepth:sDepth)
newText.font = UIFont (name: "Arial", size: 3)
newText.firstMaterial!.diffuse.contents = UIColor.whiteColor()
newText.firstMaterial!.specular.contents = UIColor.whiteColor()
newText.getBoundingBoxMin(v1, max: v2)
_textNode = SCNNode(geometry: newText)
_textNode.getBoundingBoxMin(v1, max: v2)
}
非常感谢您的建议。