SceneKitDemo icon indicating copy to clipboard operation
SceneKitDemo copied to clipboard

property 'textSize' for SCNText ?

Open zhxf2012 opened this issue 9 years ago • 2 comments

SceneKitDemo-master/SCNText/ViewController.m:158:56: error: property 'textSize' not found on object of type 'SCNText *' self.textNode.position = SCNVector3Make(-sceneText.textSize.width / 2 * textScale, -sceneText.textSize.height / 2 * textScale, 0);

zhxf2012 avatar Nov 14 '16 06:11 zhxf2012

Try to get the required property of sceneText following way

SCNVector3 min = SCNVector3Zero;
SCNVector3 max = SCNVector3Zero;
[sceneText getBoundingBoxMin:&min max:&max];
CGFloat textHeight = max.y - min.y;
CGFloat textWidth = max.x - min.x;
   
self.textNode.position = SCNVector3Make(-textWidth / 2 * textScale, -textHeight / 2 * textScale, 0);

dmitriyl avatar Jul 12 '17 10:07 dmitriyl

The textSize property is only available on macOS 10.8+. By this, I mean that if you are building a MacOS app then the variable will be accessible, whereas if you are building for IOS it is not.

If you want to get the size of your SCNText you can use it's boundingBox property to get its width and height etc.

BlackMirrorz avatar Aug 22 '18 23:08 BlackMirrorz