2012-05-05 67 views

回答

0

使用下列拍攝拍攝圖像代碼和導入<QuartzCore/QuartzCore.h>。您也可以在拍攝圖像後使用此代碼。所以你可以從中刪除不必要的部分。

UIGraphicsBeginImageContext(self.view.frame.size); 
    //or 
    UIGraphicsBeginImageContextWithOptions(self.view.frame.size, NO, 0.0);//this will also give you scaling option and more better for resolution. 

    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 

    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); 

    CGImageRef ref = viewImage.CGImage; 


    CGRect myImageArea = CGRectMake (20, 20, 
            300, 100);// you define coordinates according your requirements. 
    CGImageRef mySubimage = CGImageCreateWithImageInRect (ref, myImageArea); 

    UIImage *yourfinalcapturedimage = [UIImage imageWithCGImage:mySubimage];// this will give you your required image. 

希望,這將幫助你..