I have a label in my TableView
Cell and trying to autofit it to the size of the content. It works, but when I add a background color, I see what's wrong here. In my cell, I have a top, left, bottom and right constraint, as you can see in the picture.
How can I adjust the label size to the content?
Edit: I also have this:
override func awakeFromNib() {
super.awakeFromNib()
labelChatMessage.sizeToFit()
labelChatMessage.layoutIfNeeded()
// Initialization code
}
I have also tried this UI in one of my project.
Try doing this if it serves your purpose:
Select the Leading constraint (Left one)
Select "Show the Size Inspector"
Change the relation of the constraint to "Greater than or equal"
I think this is not required in this scenario then:
labelChatMessage.sizeToFit()
labelChatMessage.layoutIfNeeded()
because I got the output UI without that.