JohnSundell / ImagineEngine

A project to create a blazingly fast Swift game engine that is a joy to use πŸš€

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enable Label to support multiple lines of text

JohnSundell opened this issue Β· comments

Currently, the Label class only supports rendering a single line of text, and (per default) automatically resizes itself to fit that line of text. The auto-resizing can already be disabled by setting shouldAutoResize to true, but still it'll only render on a single line.

The good news is that CATextLayer (which Label uses for rendering) already supports multiple lines of text, we just need to add support for setting the isWrapped property on it to true. I suggest adding a shouldWrap property (to match shouldAutoResize in terms of naming) to Label which in turn toggles isWrapped on the underlying layer.

commented

I got this one :D

EDIT: Just closed my PR πŸ˜…. Forgot about unit test. Is it necessary for that one? It's just
public var shouldWrap = false { didSet { layer.isWrapped = shouldWrap } }

Sorry @Alex88WH, I didn't see your edit (you don't get notifications for edits) - but PR looked great πŸ‘ Thanks again for contributing πŸš€ Closing this since it's now fixed!