I have a UITableViewCell subclass alone in a xib. The cell has a UILabel subview in it. The text alignment in IB is set to center, but unless numberOfLines is set to 1, the label snaps over to left alignment (even though the "Alignment" in IB is set to center sill). I tried setting the textAlignment to NSTextAlignmentCenter in the cell's awakeFromNib, and also in the corresponding table view's cellForRowAtIndexPath:,
but still no luck, even though when I check the cell's textAlignment value at various breakpoints it's NSTextAlignmentCenter.
How can I center align multiple lines of text in a UILabel?
Of course, right after I post the question, I figure it out.
If the "Autoshrink" has "Tighten Letter Spacing" selected in IB, it snaps it to the left alignment. Uncheck this to have it stay centered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With