I wanted to create an SKLabelNode, which is supposed to have always the same length (for a word guessing game). Unfortunately SKLabelNode decides to always cut off any leading and trailing spaces. This behavior is not described in the documentation. How can I avoid/switch off that behavior?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
If you simply want labels to line up so that they are right aligned, then use a right alignment mode.
However, if you are trying to create a rectangle around the SKLabelNode, then you'll find calculateAccumulatedFrame does indeed strip any spaces before calculating the width of the label, and returns the wrong size.
But you can cheat - use a character as a dummy sizing metric to add onto your frame size.
Now add as many multiples of fOneSpace to the width of your rectangle, and it'll probably be about right.