Reputation: 3011
This is an issue with UILabel in iOS7 and iOS8, it does not present in iOS9. This odd UILabel behaviour is experienced with different fonts, in Xcode versions 6 and 7 with Swift, using the simulator and device.
Problem:
I have a UILabel that has a center text alignment. At different font sizes, some lines of text stop being center aligned and snap to left alignment. It is subtle but noticeable.
In the images below:
LEFT: all lines of text are centered neatly.
MIDDLE: after increasing the font size, the third line from the top snaps more to the left instead of remaining centered. (Notice more blue space on right.)
RIGHT: after increasing the font size a little more, both the second and third line from the top snap to the left instead of remaining centered. (Notice more blue space on right.)
Questions:
Upvotes: 1
Views: 1374
Reputation: 48514
UITextView
With all due respect, it is my experience that UILabel
is plagued with bugs when it comes to multiple lines (Line count other than 1
).
Starting, but not limited to sizing cells containing such labels hardly able to predict its footprint1.
Use UITextView
, non editable, scrolling disabled (that is the key). You will achieve the same effects, with more control over the final appearance.
1 See note 3 on this Stack Overflow UILabel
answer.
Upvotes: 1