I have 3 hidden Labels, after a check from database i set label.isHidden = false
only if the value of that label exists.
This is the situation when all labels have right value
So I'm using Storyboard with AutoLayout for determinate the position of these labels but i need to pull labels to left if one of these still hidden keeping the space with other labels.
Is it possible to do it programmatically? If yes, how?
One way to achieve this would be to align each label relative to the adjacent label (label1.trailing to label2.leading for example).
Then instead of setting any label to hidden you can set the width constraint to 0 and call layoutIfNeeded
on the superview, all other labels will then layout accordingly.
Use StackView to handle this Space instead of using isHidden to hide the label.
You can also achive that by AutoLayout, use yourConstraint.constant = 0 or priority property of the constraints.
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.