用这个方法[UIImage imageWithCGImage:img.CGImage scale:2.0 orientation:UIImageOrientationRight]
想旋转UIImage90度 但是毫无效果
用这个方法[UIImage imageWithCGImage:img.CGImage scale:2.0 orientation:UIImageOrientationRight]
想旋转UIImage90度 但是毫无效果
下面的代码可以正确旋转图片。
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];
2 回答1k 阅读
1 回答1.1k 阅读✓ 已解决
1 回答2.7k 阅读
1 回答1.5k 阅读
1 回答1.4k 阅读
1.7k 阅读
1 回答902 阅读
你那个原图片 img 的 orientation 是什么?我猜可能本来就是 right,所以重新建一个 orientation 是 right 的 UIImage 是没有任何变化的。
你需要先修正一下原图片的方向:https://gist.github.com/alex-cellcity/1531596