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

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

    Any calculations that you do based on the imageView's frame should probably be done before you apply any transformations to it. But I would actually suggest doing those calculations based on the size of the UIImage, not the UIImageView. Then set both the UIImageView's frame and the UIScrollView's contentSize based on that.

    Max's suggestion is a good one, although with a larger image it could be a performance killer. Are you displaying this image from your app's resources? If so, why not just rotate the images before you even build the app?

提交回复
热议问题