iOS-image图片旋转方向

 最近在做项目的时候发现资源包内的图片的方向不对,但也不想让UI切一个新图,所以需要将原有的图片改变其方向。

UIImage *backImage = [UIImage imageNamed:@"图片名字"];

//改变该图片的方向
backImage = [UIImage imageWithCGImage:backImage.CGImage 
                                scale:backImage.scale 
                          orientation:UIImageOrientationDown];

以下是图片方向的选择(添加了一些个人理解):

UIImageOrientationUp,            // 默认方向
UIImageOrientationDown,          // 让默认方向旋转180度
UIImageOrientationLeft,          // 让默认方向逆时针旋转90度
UIImageOrientationRight,         // 让默认方向顺时针旋转90度
UIImageOrientationUpMirrored,    // 默认方向的竖线镜像
                                 //(即以原图的左(或右)边的竖线为对称轴,对原图进行对称投影得到的镜像)
UIImageOrientationDownMirrored,  // 让镜像旋转180度
UIImageOrientationLeftMirrored,  // 让镜像逆时针旋转90度
UIImageOrientationRightMirrored, // 让镜像顺时针旋转90度

 

 

 

你可能感兴趣的:(iOS-UI成长之路)