1
我不想黑色邊框當我採取的截圖,這是我作爲圖像輸出。我用這個代碼輸出圖像(的XCode 6.2客觀C) 代碼:
UIGraphicsBeginImageContext(self.outputView.bounds.size);
[self.outputView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *sourceImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIGraphicsBeginImageContextWithOptions(self.outputView.bounds.size, self.outputView.opaque,0.0);
[sourceImage drawAtPoint:CGPointMake(0,0)];
UIImage *croppedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(croppedImage,nil, nil, nil);
NSData *pngData2 = UIImagePNGRepresentation(croppedImage);
NSArray *paths2 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath2 = [paths2 objectAtIndex:0];
NSString *filePath2 = [documentsPath2 stringByAppendingPathComponent:@"screen.png"];
[pngData2 writeToFile:filePath2 atomically:YES];