【问题标题】:How To Get Image With Correct Direction From Asset如何从资产中获取正确方向的图像
【发布时间】:2016-07-28 13:48:45
【问题描述】:

如何使用校正方向旋转图像

我在下面放了代码,但没有工作

UIImage *images  = [UIImage imageWithCGImage:[rep fullScreenImage] scale:[rep scale] orientation:0];

【问题讨论】:

    标签: ios objective-c


    【解决方案1】:

    UIImageOrientation 指定图像的可能方向:

    typedef enum {
       UIImageOrientationUp,
       UIImageOrientationDown ,   // 180 deg rotation 
       UIImageOrientationLeft ,   // 90 deg CW 
       UIImageOrientationRight ,   // 90 deg CCW 
       UIImageOrientationUpMirrored ,    // as above but image mirrored along 
           // other axis. horizontal flip 
       UIImageOrientationDownMirrored ,  // horizontal flip 
       UIImageOrientationLeftMirrored ,  // vertical flip 
       UIImageOrientationRightMirrored , // vertical flip 
    } UIImageOrientation;
    

    在您的代码中,您传递了0,这意味着UIImageOrientationUp 枚举值,对您而言,它当然看起来像默认图像。
    因此,您需要将此参数指定为您想要的方向。

    例如以下代码将进行垂直图像翻转:

    UIImage *images = [UIImage imageWithCGImage:[rep fullScreenImage] scale:[rep scale] orientation: UIImageOrientationLeftMirrored];
    

    【讨论】:

      猜你喜欢
      • 2021-11-23
      • 2013-12-27
      • 1970-01-01
      • 2019-11-30
      • 2021-10-17
      • 1970-01-01
      • 1970-01-01
      • 2016-04-16
      相关资源
      最近更新 更多