I use xib to creat a chat bubble tableViewCell, but I use auto layout to set the constrains.
It show my text out of range which I input.
And I also don't want to shrink the text.
And I also add textLabel left constrain, It makes different type which I want.
I don't want to show the empty region of chat bubble like last picture.
What should I do about this situation?
Update:
class ChatMyTextTableViewCell: UITableViewCell {
@IBOutlet weak var myImageView: UIImageView!
@IBOutlet weak var myTextLabel: PaddingLabel!
@IBOutlet weak var myDateLabel: UILabel!
@IBOutlet weak var labelWidthConstraint: NSLayoutConstraint!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
self.backgroundColor = defaultBackgroundColor
myImageView.layer.masksToBounds = true
myImageView.layer.cornerRadius = defaultIconRadius
myTextLabel.backgroundColor = defaultChatGreenBubbleColor
myTextLabel.layer.masksToBounds = true
myTextLabel.layer.cornerRadius = defaultButtonRadius
myDateLabel.textColor = defaultChatTimeColor
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func loadMessage(_ message:Message) {
labelWidthConstraint.constant = UIScreen.main.bounds.size.width - 120
myTextLabel.text = message.content
myTextLabel.autoresizingMask = [.flexibleWidth,.flexibleHeight]
myDateLabel.text = convertToChatDate(date: message.datetime)
}
}