Reputation: 7766
I have an autolayout question. I have some labels in a row, which are inside a view, which is inside another view.
I've only set the height of the outer view.
I've no idea how the the height of the inner view and labels are derived.
I have constraints for everything else. E.g. a label has.. Leading space Proportional width top space trailing space
Content hugging priority - 251 Content compression - 750 Intrinsic size - default
I've been reading about intrinsic content size and Compression Resistance and Content Hugging. I've tried changing the font size of my labels thinking this would increase the size, but it doesn't.
I'm not sure what's going on but autolayout is satisfied?
Edit: Constraints - as requested
Constraints of inner view
"<NSLayoutConstraint:0x7b3e0290 UILabel:0x7b36abd0'12'.width == 0.17*UIView:0x7b3d9e50.width>",
"<NSLayoutConstraint:0x7b3646d0 H:|-(0)-[UILabel:0x7b36abd0'12'] (Names: '|':UIView:0x7b3d9e50 )>",
"<NSLayoutConstraint:0x7b363680 V:|-(0)-[UILabel:0x7b36abd0'12'] (Names: '|':UIView:0x7b3d9e50 )>",
"<NSLayoutConstraint:0x7b362b30 UILabel:0x7b36a390'x'.width == 0.15*UIView:0x7b3d9e50.width>",
"<NSLayoutConstraint:0x7b362440 H:[UILabel:0x7b36abd0'12']-(4)-[UILabel:0x7b36a390'x']>",
"<NSLayoutConstraint:0x7b362050 V:|-(0)-[UILabel:0x7b36a390'x'] (Names: '|':UIView:0x7b3d9e50 )>",
"<NSLayoutConstraint:0x7b35fa90 V:|-(0)-[UILabel:0x7b3ee210'12'] (Names: '|':UIView:0x7b3d9e50 )>",
"<NSLayoutConstraint:0x7b35f5d0 H:[UILabel:0x7b36a390'x']-(4)-[UILabel:0x7b3ee210'12']>",
"<NSLayoutConstraint:0x7b360230 UILabel:0x7b3ee210'12'.width == 0.16*UIView:0x7b3d9e50.width>",
"<NSLayoutConstraint:0x7b35e6d0 H:[UILabel:0x7b3ee210'12']-(4)-[UILabel:0x7b36d800'=']>",
"<NSLayoutConstraint:0x7b364bf0 V:[UILabel:0x7b36d800'=']-(0)-| (Names: '|':UIView:0x7b3d9e50 )>",
"<NSLayoutConstraint:0x7b361f10 V:|-(0)-[UILabel:0x7b36d800'='] (Names: '|':UIView:0x7b3d9e50 )>",
"<NSLayoutConstraint:0x7b364500 UILabel:0x7b36d800'='.width == 0.13*UIView:0x7b3d9e50.width>",
"<NSLayoutConstraint:0x7b357460 H:[UILabel:0x7b36bbf0'144']-(0)-| (Names: '|':UIView:0x7b3d9e50 )>",
"<NSLayoutConstraint:0x7b363580 V:|-(0)-[UILabel:0x7b36bbf0'144'] (Names: '|':UIView:0x7b3d9e50 )>",
"<NSLayoutConstraint:0x7b357b20 H:[UILabel:0x7b36d800'=']-(4)-[UILabel:0x7b36bbf0'144']>",
"<NSLayoutConstraint:0x7b358430 UILabel:0x7b36bbf0'144'.width >= 0.25*UIView:0x7b3d9e50.width>"
Upvotes: 0
Views: 64
Reputation: 4437
Check the 11 constraint in the log there you have add a bottom constraint of inner view to bottom of your label.
"<NSLayoutConstraint:0x7b364bf0 V:[UILabel:0x7b36d800'=']-(0)-| (Names: '|':UIView:0x7b3d9e50 )>",
This defines the bottom of the innerview. Hence inner view is pinned to top of a UILabel and bottom also. Thats the reason the height of inner view is derived and equal to you UILabel
Upvotes: 1
Reputation: 457
Hey you can use to create IBOutlet NSLayoutConstraint of height or width
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *lableName;
lableName.constant = lable_size;
Upvotes: 0