所以我尝试使用单元格内容 View 的自动布局来获得正确的布局。所以我的问题是,我有一个 UILabel
可以根据其文本更改其大小,并且我还有一个 UIView
作为该带有圆角的标签的背景 View 。所以我的问题是,如何强制此 UIView's
宽度比 UILabel
宽 10 点。我设法使其宽度相同,但如何强制它始终加宽一定的长度?
提前谢谢您!
最佳答案
NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:yourLabel
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:yourLabel.superview
attribute:NSLayoutAttributeWidth
multiplier:1.0
constant:10]; // <-- this
[yourLabel.superview addConstraint:widthConstraint];
关于ios - UILabel自动布局宽度问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19767951/