我正在以这种方式旋转UI
ImageView:
@H_301_2@-(IBAction)rotateImageView:(id)sender{
photoView.transform = CGAffineTransformRotate(photoView.transform,M_PI);
}
如您所见,图像可以向上或向下.是否有可能检测图像是上升还是下降,以便执行以下操作:
@H_301_2@if(image is up)....解决方法
如果您只是想知道图像是否使用仿射变换进行了旋转,正如您的问题所暗示的那样,您可以这样做:
@H_301_2@if (CGAffineTransformIsIdentity(photoView.transform)) {
// not rotated
...
} else {
// rotated
...
}
如果要检查特定的旋转,请执行以下操作:
@H_301_2@CGAffineTransform t = CGAffineTransformMakeRotation(M_PI); if (CGAffineTransformEqualToTransform(photoView.transform,t)) { // rotated by M_PI ... }请注意,只有在旋转变换的同时不将其他仿射变换应用于视图时,上述两种解决方案才有效.如果您还要应用其他变换,也许您最好只跟踪变量中的旋转状态.