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
What is wrong?
Thanks!
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With