How do I set UILabel in stackview to zero when It has no strings

73 Views Asked by At

Hi I'm trying to use AutoLayout, StackView

I have 3 UILabels in StackView.

I want to implement that when UILabel has no Strings then set UILable height to zero. But It is not working.

I understood about contents hugging So I also try to set priority but It seems not working

Anyone knows about that?

enter image description here

enter image description here

Update

I solve this problem. It was really simple.

if cell.descriptionLabel.text!.isEmpty == true {
                cell.descriptionLabel.isHidden = true
            }

That's it!!

I hope you guys solve similar problem.

1

There are 1 best solutions below

1
On BEST ANSWER

Put your height NSLayoutconstrain as IBOutlet and set it as 0 when there aren't any .text using Delegate to achieve that.

if yourLabel.text == ""{
   //here

}