I have cell with UILabel and Button . For the first time label have three rows .
When I tap on the button , number of lines increase and my cell change size, but without animation. how I can correct it?
My code inside cell:
func buttonTap() {
if textIsHide == true {
descriptionLabel.numberOfLines = 100
textIsHide = false
button.setTitle(.localized(for: "posters_postercard_hide"), for: .normal)
} else {
descriptionLabel.numberOfLines = 3
textIsHide = true
button.setTitle(.localized(for: "posters_postercard_showmore"), for: .normal)
}
delegate?.reloadRows()
descriptionLabel.layoutIfNeeded()
}
And this is my UIView, where I update my table:
extension PosterCardView: PosterCardDataManagerDelegate {
func reloadRows() {
tableView.beginUpdates()
tableView.endUpdates()
}
func buttonTap() {
if textIsHide == true {
withAnimation {
descriptionLabel.numberOfLines = 100
textIsHide = false
button.setTitle(.localized(for: "posters_postercard_hide"), for: .normal)
}
} else {
withAnimation{
descriptionLabel.numberOfLines = 3
textIsHide = true
button.setTitle(.localized(for: "posters_postercard_showmore"), for: .normal)
}
}
delegate?.reloadRows()
descriptionLabel.layoutIfNeeded()
}
have you ever tried with an animation?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.