【发布时间】:2014-05-06 17:58:10
【问题描述】:
是否可以从 UIImage 中剥离或完全删除 UIImageOrientation 信息?
我可以将image.imageOrientation = nil 设置为无吗?
我想物理旋转我的图像并去除方向。
【问题讨论】:
标签: ios objective-c cocoa-touch uiimage
是否可以从 UIImage 中剥离或完全删除 UIImageOrientation 信息?
我可以将image.imageOrientation = nil 设置为无吗?
我想物理旋转我的图像并去除方向。
【问题讨论】:
标签: ios objective-c cocoa-touch uiimage
您不能将 imageOrientation 设置为零,因为它不是对象。你可以在 UIImage 头定义文件中找到它,你会发现它被定义为一个 NSInteger
typedef NS_ENUM(NSInteger, UIImageOrientation)
除了是 NSInteger 之外,与之关联的属性是只读的,这意味着您不能直接通过 setter 方法对其进行更改:
@property(nonatomic,readonly) UIImageOrientation imageOrientation;
UIImageOrientationUp 是 UIImage 的默认方向,您可以做的是创建一个具有您想要使用/喜欢的方向的新图像,例如:
+ (UIImage *)imageWithCGImage:(CGImageRef)cgImage scale:(CGFloat)scale orientation:(UIImageOrientation)orientation NS_AVAILABLE_IOS(4_0);
【讨论】: