【代码笔记】iOS-图片旋转

代码:

RootViewController.h

#import 

@interface RootViewController : UIViewController

@end

 

RootViewController.m

复制代码
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    UIImage * image = [UIImage imageNamed:@"1.jpg"];
    NSData * tempData;
    if (UIImagePNGRepresentation(image)) {
        tempData = UIImagePNGRepresentation(image);
        NSLog(@"%@",tempData);
    }
    else{
        tempData = UIImageJPEGRepresentation(image, 1);
    }
    CIImage * iImg = [CIImage imageWithData:tempData];
    UIImage * tImg = [UIImage imageWithCIImage:iImg scale:1 orientation:UIImageOrientationRight];
    NSLog(@"%@",UIImagePNGRepresentation(tImg));
    UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 200, 200, 80)];
    imageView.image = tImg;
    [self.view addSubview:imageView];
    
}
复制代码

 

你可能感兴趣的:(iOS-代码笔记)