【发布时间】:2014-05-14 18:14:10
【问题描述】:
请查看这个带有自动布局的动态多行UILabel 的简单示例,该示例应强制其超级视图增加高度。该示例在纵向上运行良好,而在横向上,UILabel 的高度增长过多。
我在 storyboard 中设置了约束,标签的垂直压缩和拥抱优先级是 1000,superview 是 1。视图之间的所有其他顶部、底部、前导和尾随约束都是标准的。
我用非常浅的灰色为标签的背景着色,因此很明显标签的顶部和底部边距比纵向模式大得多。有人可以告诉我如何在横向上获得具有相同顶部和底部边距的标签吗?谢谢。
- (void)viewDidLoad
{
[super viewDidLoad];
self.myTextLabel.text = @"iPhone 6 rumoured to have larger display.";
}
- (IBAction)button:(UIButton *)sender
{
if (!self.flag) {
self.innerHeightConstraint.constant = 120.0;
self.myTextLabel.text = @"iPhone 6 rumoured to have larger, 1704 x 960 display. A new report indicates that Apple's testing it.";
self.flag = YES;
} else {
self.innerHeightConstraint.constant = 60.0;
self.myTextLabel.text = @"iPhone 6 rumoured to have larger display.";
self.flag = NO;
}
[self.view layoutIfNeeded];
}
【问题讨论】:
标签: ios objective-c autolayout