Reputation: 944
My user report a bug that the texts is strange and he did not taped that. So I get the texts and create a simple project, only create a label and set the texts to it. The texts is here:
【Does this sound natural?】\n \"Who's that?\" \"That's Tom when he was a kid.\" \"Do you have a same picture of Mary?
If I do not limit the number of label's line, there is no issue, but when set the number of line to 3, the text "That's Tom when
occurred two times! And texts is became strange.
All code is here
class ViewController: UIViewController {
lazy var label: UILabel = {
let label = UILabel(frame: CGRect(x: 50, y: 100, width: 220, height: 100))
label.numberOfLines = 3
label.font = UIFont.systemFont(ofSize: 14)
self.view.addSubview(label)
return label
}()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.view.backgroundColor = .lightGray
self.label.text = "【Does this sound natural?】\n \"Who's that?\" \"That's Tom when he was a kid.\" \"Do you have a same picture of Mary?"
}
}
Upvotes: 3
Views: 135
Reputation: 3853
According to the discussion here it is a bug occurring after iOS 15.4.
There is a workaround mentioned in the above thread.
I also faced the same issue and I changed the UILabel
to a UITextView
with the two options
label.textContainer.maximumNumberOfLines = 3
label.textContainer.lineBreakMode = .byTruncatingTail
Check if either of workarounds will work in your case.
Upvotes: 4