扫码关注官方订阅号
用这个方法[UIImage imageWithCGImage:img.CGImage scale:2.0 orientation:UIImageOrientationRight]想旋转UIImage90度 但是毫无效果
ringa_lee
你那个原图片 img 的 orientation 是什么?我猜可能本来就是 right,所以重新建一个 orientation 是 right 的 UIImage 是没有任何变化的。
你需要先修正一下原图片的方向:https://gist.github.com/alex-cellcity/1531596
下面的代码可以正确旋转图片。
UIImage *img = [UIImage imageNamed:@"i"]; UIImageOrientation a0 = img.imageOrientation; UIImage *image = [UIImage imageWithCGImage:img.CGImage scale:2.0 orientation:UIImageOrientationRight]; UIImageOrientation a2 = image.imageOrientation; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; [imageView sizeToFit]; [self.view addSubview:imageView];
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
你那个原图片 img 的 orientation 是什么?我猜可能本来就是 right,所以重新建一个 orientation 是 right 的 UIImage 是没有任何变化的。
你需要先修正一下原图片的方向:https://gist.github.com/alex-cellcity/1531596
下面的代码可以正确旋转图片。