【发布时间】:2023-03-28 14:11:01
【问题描述】:
我想在单击旋转按钮而不是方向更改时旋转 UIImage 而不是 UIImageView。请回复。
【问题讨论】:
标签: iphone objective-c uiimage rotation
我想在单击旋转按钮而不是方向更改时旋转 UIImage 而不是 UIImageView。请回复。
【问题讨论】:
标签: iphone objective-c uiimage rotation
CGSize size = sizeOfImage;
UIGraphicsBeginImageContext(size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextRotateCTM(ctx, angleInRadians);
CGContextDrawImage(UIGraphicsGetCurrentContext(),
CGRectMake(0,0,size.width, size.height),
image);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
【讨论】:
您可以使用imageWithCGImage:scale:orientation:(从 4.0 开始提供)
【讨论】:
【讨论】: