UIView旋转没有调整大小

时间:2016-02-08 10:10:05

标签: ios uiview autolayout uilabel

我已在UIView内创建了UILabel(如AutoLayout with rotated UI Elements中所述)。问题是当我将它旋转90度时它不想自动布局(见图片)。

旋转前的图像: Image before rotation

之后:

enter image description here

轮换完成:

yTitleView.translatesAutoresizingMaskIntoConstraints = NO;
yTitleLabel.transform = CGAffineTransformMakeRotation (-3.14/2);

SleepScoreUILabel和蓝色UIView之间的约束只是为了保持它们之间的距离:

enter image description here

EDIT1: 试过@bennegeek的建议

 yTitleLabel.translatesAutoresizingMaskIntoConstraints = YES;
    CGRect frame = yTitleLabel.frame;
    bottom.active = NO;
    top.active = NO;
    leading.active = NO;
    trailing.active = NO;
    yTitleLabel.transform = CGAffineTransformMakeRotation (-M_PI/2);

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        yTitleLabel.frame = frame;
    });

但结果是: enter image description here

如果在这些操作之后我将约束重新激活,我得到: enter image description here

0 个答案:

没有答案