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.
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!