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

前端 未结 5 1215
傲寒
傲寒 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:45

    I believe the easiest way (and thread safe too) is to do:

    //assume that the image is loaded in landscape mode from disk
    UIImage * LandscapeImage = [UIImage imageNamed: imgname];
    UIImage * PortraitImage = [[UIImage alloc] initWithCGImage: LandscapeImage.CGImage
                                                         scale: 1.0
                                                   orientation: UIImageOrientationLeft];
    

提交回复
热议问题