What is the reason why the view is deformed when rotated with CGAffineTransformMakeRotation, and how to deal with it?

CGFloat angle = 10 * M_PI / 180.f;
view.transform = CGAffineTransformMakeRotation (angle);

Ios
Mar.29,2021

I changed it to view.layer.transform = CATransform3DMakeRotation (angle, 0,0,1) to test, and found that there is only a problem with rotation relative to the z axis, which does not look like rotation around the z axis

if you use animation to rotate, there is no problem!

CABasicAnimation *circleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
view.duration = 0;
view.repeatCount = 1;
view.toValue = @(angle);
view.removedOnCompletion = NO;
view.fillMode = kCAFillModeForwards;
[view.layer addAnimation:circleAnimation forKey:@"rotation"];

the reason is that the coordinate system has been modified after using CATransform3DMakeRotation, so the frame of the view in which it is located cannot be set here. Here I set its frame many times, so it causes the problem

Menu