Transform UILabel under autolayout different in iOS7 and iOS8

486 Views Asked by At

I want to rotate uilabel, it seems different in iOS7 and iOS8. Can anyone explain why?

Here is my demo code, use pureLayout for setting autolayout:

UIView *view = [UIView newAutoLayoutView];
[self.view addSubview:view];
[view autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:20];
[view autoAlignAxisToSuperviewAxis:ALAxisVertical];
[view autoSetDimensionsToSize:CGSizeMake(20, 100)];
view.backgroundColor = [UIColor lightGrayColor];

UILabel *topLabel = [UILabel newAutoLayoutView];
[view addSubview:topLabel];
topLabel.backgroundColor = [UIColor redColor];
topLabel.text = @"The top label text";
[topLabel autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsZero excludingEdge:ALEdgeBottom];

CGAffineTransform tran = CGAffineTransformMakeRotation(-M_PI_2);
topLabel.transform = tran;

and the frame of topLabel:

iOS8:{{-1.25, 1.25}, {22.5, 20}}
iOS7:{{0, 0}, {20, 135}}

Result of iOS7 is what i wanted. And same result when i use IB to autolayout

1

There are 1 best solutions below

0
On

People seem to think it's related to constraints behaving differently in iOS 7 and 8. Animation of CGAffineTransform in iOS8 looks different than in iOS7