UILabel wrong behaviour when numberOfLines limited with byTruncatingTail lineBreakMode.
Originator: | pwl.kowalczuk | ||
Number: | rdar://FB9997889 | Date Originated: | |
Status: | Open | Resolved: | |
Product: | UIKit Framework | Product Version: | iOS 15.5 |
Classification: | Incorrect/Unexpected Behavior | Reproducible: | Always |
Text set on UILabel is repeated when it does not fit within the limit of number of lines and lineBreak mode is set to .byTruncatingTail. You can repet this behaviour in playground with this code (only iOS 15.5(iPhone X) it works on 14.8 that I have on my other iPhone SE 2): ``` import UIKit import PlaygroundSupport class MyViewController : UIViewController { let text = "aaaaaaaaaaaaa bbbbbbb cccccc\n\nddddd eee ffff ggggggggg hhhh, iiiii jjjjjjj, kkk llll mmmmmmmmmmmm nnn ooooooo uuuuuu ppppppp rrrrrr ssss" override func loadView() { let view = UIView() view.backgroundColor = .white let label = UILabel() view.addSubview(label) label.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ label.topAnchor.constraint(equalTo: view.topAnchor), label.leadingAnchor.constraint(equalTo: view.leadingAnchor), label.trailingAnchor.constraint(equalTo: view.trailingAnchor), label.bottomAnchor.constraint(equalTo: view.bottomAnchor) ]) self.view = view label.text = text label.lineBreakMode = .byTruncatingTail label.numberOfLines = 4 } } // Present the view controller in the Live View window PlaygroundPage.current.liveView = MyViewController() ```
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!