【问题标题】:Rotating UIImageView旋转 UIImageView
【发布时间】:2013-01-18 13:44:23
【问题描述】:

我想旋转一个 UIImageView,我正在使用这个代码:

-(IBAction)rotateImageView:(id)sender{
 photoView.transform = CGAffineTransformMakeRotation(M_PI); //rotation in radians
}

代码有效。当我按下按钮时,图像会旋转 180 度,但如果我再次按下它,它不会旋转回原来的位置,而是保持静止。为什么??

【问题讨论】:

    标签: ios xcode


    【解决方案1】:

    因为您再次对视图应用相同的变换,而不考虑任何现有的变换。

    试试这个:

    photoView.transform = CGAffineTransformRotate(photoView.transform,M_PI);

    【讨论】:

    • 出于某种原因这样做:-(IBAction)rotateImageView:(id)sender{ CGAffineTransformRotate(photoView.transform, M_PI); } 不起作用
    • 抱歉,我忘记添加作业了。
    【解决方案2】:

    您必须从当前旋转中旋转 imageView 以使其原始

    使用此代码

    CGAffineTransformRotate(photoView.transform, M_PI);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-19
      • 2012-05-16
      相关资源
      最近更新 更多