CGRect rect1 = backgroundImageView.frame;
NSLog(@"%f,%f,%f,%f",rect1.origin.x,rect1.origin.y,
rect1.size.width,rect1.size.height);
angle = -90.0;
moveX = 0;
moveY = 0.0;
CGFloat degreesToRadians = M_PI * angle / 180.0;
CGAffineTransform landscapeTransform =
CGAffineTransformMakeRotation(degreesToRadians);
landscapeTransform =
CGAffineTransformTranslate(landscapeTransform, moveX, moveY);
[backgroundImageView setTransform:landscapeTransform];
rect1 = backgroundImageView.frame;
NSLog(@"%f,%f,%f,%f",rect1.origin.x,rect1.origin.y,
rect1.size.width,rect1.size.height);
调试消息输出:
0.000000,0.000000,320.000000,480.000000
-80.000000,80.000000,480.000000,320.000000
为什么(x,y)变为(-80,80)?
答案 0 :(得分:0)
设置转换时,backgroundImageView.center不会更改。如果父视图已经旋转,则应用变换后可以执行类似的操作。
backgroundImageView.center = backgroundImageView.superview.center;
无论哪种方式,为了您的目的,您应该调整中心而不是转换变换。