Reputation: 2408
Is there anyway to set the height of a UILabel programmatically? I've added a bunch of constraints to my .Xib files so every other label is dependent upon the one above or below it for it's positioning. It'd make my life so much easier if I could just use:
nameLabel.height = 0
My .Xib looks like this:
Upvotes: 1
Views: 1408
Reputation: 537
If you empty the label its height will be zero.
nameLabel.text = ""
Even no need to hide it.
Upvotes: 0
Reputation: 3244
Write this line :
constLblHeight.constant = 0;
//Below image step
//Step 1: Add Constraint in label height
//Step 2: Create object of label height constraint (constLblHeight)
Upvotes: 0
Reputation: 2786
plz take the IBoutlet of constraint height and set the height you want
Upvotes: 4
Reputation: 6394
try this:
var frame: CGRect = nameLabel.frame
frame.size.height = height
nameLabel.frame = frame
Upvotes: 0