原鏈接:https://www.shuzhiduo.com/A/QV5ZPbjbzy/
最近在做項目的時候發(fā)現(xiàn)資源包內的圖片的方向不對摊册,但也不想讓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度