Hi,
I just discovered a weird bug with UITextView on iOS 16 beta 4.
For some reason now, when the scrolling is disabled, the intrinsic content size of the text view is considering the line spacing even when the textview is empty.
For example, in the below code we are setting a big lineSpacing
of 50 to the text view typingAttributes
attribute.
class ViewController: UIViewController {
@IBOutlet weak var textView: UITextView! {
didSet {
//Let's set the textView typingAttributes with a lineSpacing of 50.
var attributes = [NSAttributedString.Key: Any]()
let paragraphStyle: NSMutableParagraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 50
attributes[NSAttributedString.Key.paragraphStyle] = paragraphStyle
attributes[NSAttributedString.Key.font] = UIFont.preferredFont(forTextStyle: .body)
textView.typingAttributes = attributes
}
}
}
On previous iOS versions, everyting it's ok and the line spacing is added only when there are more than one line (see below image).
However, on iOS 16 beta 4, the line spacing is added also when the content is empty (see below image on the left). A soon as we type something the height collapse to the correct height (see below image in the center).
Is this a new expected behavior or a bug? If it is a bug, someone has found a temporary fix for that?
Thank you