Kian
Kian

Reputation: 122

frame size of view not changing in iOS 11

My app has a button which rotates my view 90 degrees and changes its frame accordingly so it fills the screen in landscape.

The code is as following:

CGAffineTransform transform = CGAffineTransformRotate(self.tabsView.transform, M_PI_2);

self.tabsView.transform = transform;


CGRect newFrame = CGRectMake( self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);

self.tabsView.frame = newFrame;

It works like a charm on iOS 10 and lower: Lanscape iOS 10

But running it on Xcode 9 beta 6 in the iOS 11 simulator I get this result: Landscape iOS 11

Is this a bug or did anything change in this version I don't know about? I use Auto Layout.

Upvotes: 0

Views: 2099

Answers (1)

Kian
Kian

Reputation: 122

I just found the solution. It was necessary to add this line of code:

self.tabsView.translatesAutoresizingMaskIntoConstraints = YES;

It translates the views autoresizing mask into Auto Layout constraints. With that I have the same result on both iOS versions.

Upvotes: 2

Related Questions