その上に、別のクラスであるMainViewControllera を追加しています。UIView iSnap
MainViewController今、クラスのビューの一部をキャプチャしたいと思いiSnapます。出来ますか ?
MainViewController現在のView Controllerのビューから画像をキャプチャする方法は知っていますが、ここではiSnapクラス内のビュー部分をキャプチャしたいと考えています。
このコードは、iSnap クラスに存在する画像をキャプチャするために使用しています。
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
UIGraphicsBeginImageContextWithOptions(grabRect.size, NO, [UIScreen mainScreen].scale);
} else {
UIGraphicsBeginImageContext(grabRect.size);
}
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(ctx, -grabRect.origin.x, -grabRect.origin.y);
[self.layer renderInContext:ctx];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);