`- (void)rotateTapped:(id)sender {
UIImage *currentImage = _imageView.image;
CGImageRef currentCGImage = currentImage.CGImage;
CGSize originalSize = currentImage.size;
CGSize rotatedSize = CGSizeMake(originalSize.height, originalSize.width);
CGContextRef context = CGBitmapContextCreate(NULL,
rotatedSize.width,
rotatedSize.height,
CGImageGetBitsPerComponent(currentCGImage),
CGImageGetBitsPerPixel(currentCGImage) * rotatedSize.width,
CGImageGetColorSpace(currentCGImage),
CGImageGetBitmapInfo(currentCGImage));
CGContextTranslateCTM(context, rotatedSize.width, 0.0f);
CGContextRotateCTM(context, M_PI_2);
CGContextDrawImage(context, (CGRect){.origin=CGPointZero, .size=originalSize}, currentCGImage);
CGImageRef newCGImage = CGBitmapContextCreateImage(context);
UIImage *newImage = [UIImage imageWithCGImage:newCGImage];
self.imageView.image = newImage;
}
`