Thursday, October 29, 2026
HomeiOS Developmentios - Why row peak is squeezing after scroll for tableView in...

ios – Why row peak is squeezing after scroll for tableView in swift?

[ad_1]

I’m utilizing a tableView and with the tableView I’m utilizing a label and my requirement is to make the label auto-adjusting in line with the textual content. So I’m calculating dynamic peak for my label. It’s working fantastic initially however after scroll the peak of the label is diminished. I do not know why.

// to calculate dynamic peak of the label
    func peak(constraintedWidth width: CGFloat, font: UIFont) -> CGFloat {
        let label =  UILabel(body: CGRect(x: 0, y: 0, width: width, peak: .greatestFiniteMagnitude))
        label.numberOfLines = 0
        label.lineBreakMode = .byWordWrapping
        label.textual content = self
        label.font = font
        label.sizeToFit()

        return label.body.peak
     }

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments