Here's my subclass :
class LabelWithBlackBackGround: UILabel {
var topInset = CGFloat(3)
var bottomInset = CGFloat(3)
var leftInset = CGFloat(15)
var rightInset = CGFloat(10)
override func drawText(in rect: CGRect) {
let insets: UIEdgeInsets = UIEdgeInsets(top: topInset, left: leftInset, bottom: bottomInset, right: rightInset)
super.drawText(in: UIEdgeInsetsInsetRect(rect, insets))
}
override public var intrinsicContentSize: CGSize {
var intrinsicSuperViewContentSize = super.intrinsicContentSize
intrinsicSuperViewContentSize.height += topInset + bottomInset
intrinsicSuperViewContentSize.width += leftInset + rightInset
return intrinsicSuperViewContentSize
}
deinit {
}
}
Problem is, when I have multiple lines, a lot of times it's truncating my text, like so :
It's probably my intrinsicContentSize that is not right, but I can't find what's wrong with it.
Of course, I tried with those :
label.numberOfLines = 0
label.lineBreakMode = .byWordWrapping