CGImageRef

使用CGImageRef进行图片截取

 

例:将一张图片截成两张图

    UIImage *image = [UIImage imageNamed:@"1111.jpg"];

    CGImageRef refImage = CGImageCreateWithImageInRect(image.CGImage, CGRectMake(0, 0, image.size.width, image.size.height *0.5));

    UIImage *image1 = [UIImage imageWithCGImage:refImage];

    _myImage.image = image1;

    

    _myImage1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, HEIGHT *0.5, WIDTH, HEIGHT *0.5)];

    [self.view addSubview:_myImage1];

    

    CGImageRef refImage1 = CGImageCreateWithImageInRect(image.CGImage, CGRectMake(0, image.size.height *0.5, image.size.width, image.size.height *0.5));

    UIImage *image2 = [UIImage imageWithCGImage:refImage1];

    _myImage1.image = image2;

 

posted @ 2016-03-01 11:00  zk·mark  阅读(395)  评论(0编辑  收藏  举报