Search code examples
objective-cipadios6uiimageviewuiimage

How to rotate UIImage


I'm developing an iOS app for iPad. Is there any way to rotate a UIImage 90º and then add it to a UIImageView? I've tried a lot of different codes but none worked...

Thanks!


Solution

  • You may rotate UIImageView itself with:

    UIImageView *iv = [[UIImageView alloc] initWithImage:image];
    iv.transform = CGAffineTransformMakeRotation(M_PI_2);
    

    Or if you really want to change image, you may use code from this answer, it works.