CGAffineTransformScale changed after device rotation

I have an idea that I am converting to

originalTransform = self.appContainer.transform; self.appContainer.transform = CGAffineTransformMakeScale(.8, .8); 

Original rotation

If I do not rotate the device, I can return it back to the original with

 self.appContainer.transform = CGAffineTransformScale(originalTransform, 1, 1); 

Unfortunately, if I rotate the device, the transformation matrix for the view changes by rotating the view and breaks the original scale. If I cancel the scale after rotation, I will stay with UIView without returning to the original full-size.

After rotation

After original scale

I am sure that I need to make calculations between the original transformation matrix and the new one, but I'm not sure how to do it. The only thing I could do to make this work was to return the scale to 1 before rotating

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { self.appContainer.transform = CGAffineTransformScale(originalTransform, 1, 1); } 

And then drag it with the modified transform after

 -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { self.appContainer.transform = CGAffineTransformMakeScale(.8, .8); } 

This makes it work as I expect, but instead of returning to full-screen mode and then returning to the .8 scale, I would like it to move from a new conversion to the correct .8 scale.

+4
source share
2 answers

If you want to return it to the original, try setting the conversion to CGAffineTransformIdentity.

 self.appContainer.transform = CGAffineTransformIdentity; 
0
source

I think you need to remove all autoresist masks using .....

 [self.appContainer setAutoresizingMask:UIViewAutoresizingNone]; 
0
source

Source: https://habr.com/ru/post/1411572/


All Articles