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

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

    I was using the accepted answer for a while until we noticed that non-square rotations based on images taken directly from the camera seemed stretched (they were rotated as desired, just the frame width/height wasn't adjusted).

    Great explanation/post here from Trevor: http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/

    In the end, it was a very simple import of Trevor's code which uses categories to add a resizedImage:interpoationQuality method to UIImage. So yeah, user beware, if it still works for you, great. But if it doesn't, I'd take a look at the library instead.

提交回复
热议问题