How to I rotate UIImageView by 90 degrees inside a UIScrollView with correct image size and scrolling?

前端 未结 5 1164
傲寒
傲寒 2021-02-02 04:37

I have an image inside an UIImageView which is within a UIScrollView. What I want to do is rotate this image 90 degrees so that it is in landscape by default, and set the initi

5条回答
  •  面向向阳花
    2021-02-02 04:50

    There's a much easier solution that is also faster, just do this:

    - (void) imageRotateTapped:(id)sender
    {
        [UIView animateWithDuration:0.33f animations:^()
        {
            self.imageView.transform = CGAffineTransformMakeRotation(RADIANS(self.rotateDegrees += 90.0f));
            self.imageView.frame = self.imageView.superview.bounds; // change this to whatever rect you want
        }];
    }
    

    When the user is done, you will need to actually create a new rotated image, but that is very easy to do.

提交回复
热议问题