画像関連のアプリを作っています。画面に複数の画像があります。私はそれのスクリーンショットを撮っていました。でも、限られた範囲でスクリーンショットを撮りたいので、基本的にはスクリーンショットのフレームを限定したいです。以下はスクリーンショットの私のコードです。
-(UIImage *) screenshot
{
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, YES, [UIScreen mainScreen].scale);
[self.view drawViewHierarchyInRect:self.view.frame afterScreenUpdates:YES];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
スクリーンショットを撮った後、Facebookの共有方法で以下のコードで使用しています。
UIImage *image12 = [self screenshot];
[mySLComposerSheet addImage:image12];