Is it possible to strip or completely remove UIImageOrientation information from a UIImage?

Can I set image.imageOrientation = nil or to nothing?

I want to physically rotate my image and strip the orientation.

有帮助吗?

解决方案

You can not set to nil the imageOrientation since it's not an object. You could find it in the UIImage header definition file and you'll find it's defined as a NSInteger

typedef NS_ENUM(NSInteger, UIImageOrientation)

Apart from being a NSInteger the property associate to it is readonly, which means you can not change it directly through setter method:

@property(nonatomic,readonly) UIImageOrientation imageOrientation;

UIImageOrientationUp is the default orientation for UIImage, what you could do is to create a new image with the orientation you want to use/prefer using for example:

+ (UIImage *)imageWithCGImage:(CGImageRef)cgImage scale:(CGFloat)scale orientation:(UIImageOrientation)orientation NS_AVAILABLE_IOS(4_0);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top