我已在UIView
内创建了UILabel
(如AutoLayout with rotated UI Elements中所述)。问题是当我将它旋转90度时它不想自动布局(见图片)。
之后:
轮换完成:
yTitleView.translatesAutoresizingMaskIntoConstraints = NO;
yTitleLabel.transform = CGAffineTransformMakeRotation (-3.14/2);
SleepScoreUILabel
和蓝色UIView
之间的约束只是为了保持它们之间的距离:
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;
});