您的位置:首页 > 产品设计 > UI/UE

Rotate a UIImage by 90 degree angles

2014-07-13 15:07 330 查看


Rotate a UIImage by 90 degree angles

I was looking for an easy way to rotate an image by 90 degrees and all the methods I used lots of code & required redrawing the image, normally with a transform, then getting the image from that. All I wanted was to quickly and easily rotate a UIImage by 90
degree angles so didn’t care about being able to precisely rotate by any angle.
    UIImage *image = //... create an image
    image = [UIImage imageWithCGImage:image.CGImage scale:image.scale orientation:UIImageOrientationRight];

UIImageOrientationUp : 0°/360°
UIImageOrientationRight : 90°
UIImageOrientationLeft : 270°
UIImageOrientationDown : 190°

UIImageOrientation
Reference

A note though if you then rotate that image it’ll rotate relative to it’s current rotation. “image.imageOrientation”
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: