2013-04-04 93 views

回答

0

试试这个:

UIGraphicsBeginImageContext(self.view.bounds.size); 
// retrieve the current graphics context 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
// render view into context 
    [self.view.layer renderInContext:context]; 
// create image from context 
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 
    image=[self cropImage:image]; 
    UIGraphicsEndImageContext(); 

    - (UIImage *)cropImage:(UIImage *)oldImage { 
     CGSize imageSize = oldImage.size; 
     UIGraphicsBeginImageContextWithOptions(CGSizeMake(imageSize.width,imageSize.height - 150),NO,0.); //set your height and width 
      [oldImage drawAtPoint:CGPointMake(0, -80) blendMode:kCGBlendModeCopy alpha:1.]; 
      UIImage *croppedImage = UIGraphicsGetImageFromCurrentImageContext(); 
      UIGraphicsEndImageContext(); 
      return croppedImage; 
    } 
0

像这样:

CGImageRef imageRef = CGImageCreateWithImageInRect([bigImage CGImage], cropRect); 
UIImage *croppedImage = [UIImage imageWithCGImage:imageRef]; 
CGImageRelease(imageRef); 
相关问题