I have UITableViewCell that becomes invisible by setting its height to zero:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return isCollapsed ? 0 : 50
}
Inside that cell I constraint every view from top to bottom of cell's view. And every view except UIButton works. But UIButton text doesn't disappear when cell's height is zero. I think it has to do with UIButton text not depending on parent height. UIButton background color does disappear when cell is collapsed. Best solution that I found is to use UILabel instead. But it doesn't have touch animation. Is there another solution without manually hiding the button?
Swift 3.0
UIButton
is subclass ofUILabel
. If your set hight to zero of button, butUILabel
hight is not zero.You need to hidden that button. then its not appear in cell while hight ofcell
is zero.