0

次のコードを使用して、UIView を画像としてキャプチャしています

-(void)startSnapSot {
    NSLog(@"TakeSnapShot");

        UIImage* image = nil;

        //   image = [self screenshot];
        UIGraphicsBeginImageContext(overlayView.frame.size);
        {
            [overlayView.layer renderInContext: UIGraphicsGetCurrentContext()];
            image = UIGraphicsGetImageFromCurrentImageContext();
        }
        UIGraphicsEndImageContext();

        ALAssetsLibraryWriteImageCompletionBlock completionBlock = ^(NSURL *assetURL, NSError *error) {
            if (error) {
                NSLog(@"Error Saving Image");
            }
            else {
                NSLog(@"Image Saved");
            }
        };

        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        [library writeImageToSavedPhotosAlbum:[image CGImage]
                                  orientation:(ALAssetOrientation)[image imageOrientation]
                              completionBlock:completionBlock];
}

しかし問題は、最初の画像を何度も保存していることです。つまり、別の UIIView 画像をキャプチャするのではなく、同じ画像を何度も保存しています。

4

0 に答える 0