I use UITextView to show multiline text.i know after ios16 ,apple use TextKit2 as the default engine for UITextView,and its buggy.By accessing uitextview.layoutmanager or use the init func ,it can fallback to textkit1.
if #available(iOS 16.0, *) {
contentText = UITextView(usingTextLayoutManager: false)
} else {
contentText = UITextView()
}
but on iphone15,15pro and 14pro,even I use UITextView,UITextView still not show last line like this:
enter image description here
but it’s expected to be this:
enter image description here
I found its the same when I turn on TextKit2.
so I wonder if apple force use textkit2 on iPhone 15 ,15pro,14pro even I try to turn off it ?
if not ,how can I fix this bug ?
I custom my UITextView like below:
contentText?.labled()
contentText?.style(5, UIFont.systemFont(ofSize: 17.scaled()))
func labled()
{
self.isSelectable = true
self.isEditable = false
self.isScrollEnabled = false
self.showsVerticalScrollIndicator = false
self.showsHorizontalScrollIndicator = false
self.textContainer.lineFragmentPadding = 0
self.textContainerInset = .zero
self.translatesAutoresizingMaskIntoConstraints = false
self.textAlignment = .left
}
func style(_ space:CGFloat,_ font:UIFont)
{
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = space.scaled()
let attribytes = [NSAttributedString.Key.paragraphStyle:paragraphStyle,
NSAttributedString.Key.font:font]
self.typingAttributes = attribytes
}
I tried everything I can do , but it seems that on iPhone 15,15pro,14pro,you cannot fallback to textkit1
ps:if I append an extra “\n” to the text, it can show all lines.i don’t know why.but it make an extra space and ugly.