I'm trying to use programmatic visual constraints to display a label and a button next to one another. However, the UIImageView
used as the button's background is making the intrinsic size of the button much too large.
I attempted to add a constraint that forces the height of the button to match the height of the label. But I just got a super tall label instead of a smaller button.
The following works for this:
@"|-[titleLabel][refreshButton(==26)]"
Add a constraint such that the height of the button is equal to its own (now explicit) width:
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:refreshButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:refreshButton attribute:NSLayoutAttributeWidth multiplier:1.0f constant:0.0f];
I would still prefer a solution that uses the label's height, instead of a fixed value.
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.