次のコードでUIImageViewのスクリーンショットを撮るアプリがあります。
-(IBAction) screenShot: (id) sender{
UIGraphicsBeginImageContext(sshot.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage,nil, nil, nil);
}
これはうまく機能しますが、スクリーンショットを撮る場所に配置できる必要があります。基本的には、画面の3分の1(中央部分)だけをグレーディングする必要があります。使ってみました
UIGraphicsBeginImageContext(CGSize 150,150);
しかし、すべてのものが0,0座標から取得されていることがわかり、これを正しく配置する方法を誰かが知っています。