UILabel自动版式剪切文本的结尾

时间:2019-03-16 16:19:16

标签: autolayout uilabel iphone-x

一个简单的问题-为什么会这样?...

是iPhone X Max,是iPhone X)

enter image description here

UILabel *label = UILabel.new;
label.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:mediumFontSize()];
label.textColor = customBlackColor();

label.translatesAutoresizingMaskIntoConstraints = NO;
label.text = message;
label.numberOfLines = 0;
label.backgroundColor = UIColor.debug_color;
[self addSubview:label];

[label.widthAnchor constraintEqualToAnchor:self.widthAnchor multiplier:.8].active = YES;
[label.topAnchor constraintEqualToAnchor:image.bottomAnchor constant:defaultUISpacing()].active = YES;
[label.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
...

// I then set the bottom anchor of the label to the bottom of the cell.

无论出于何种原因,标签都无法正确计算X Max上的帧,仅显示全文就不够了。有想法吗?


仅供参考:我使用的是 Arial Rounded MT Bold 作为我的字体,并且标签在其他所有iPhone格式上都可以正确计算。

也:是我尝试了[label sizeToFit],但没有成功。结果相同。


编辑

调用label.adjustsFontSizeToFitWidth = YES可以达到预期的效果。仍然想知道为什么它在X Max上不起作用,但是在没有此功能的情况下在其他地方都能起作用...

0 个答案:

没有答案
相关问题