Wednesday, June 20, 2012

How to Take ScreenShot and save in Photo Album

-(void)saveImageInPhotoAlbum{
    UIGraphicsBeginImageContext(
                              CGSizeMake(self.view.frame.size.width,
                                       self.view.frame.size.height));
    CGContextRef context = UIGraphicsGetCurrentContext();
    [self.view.layer renderInContext:context];
    UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    NSData *imageData = [NSData dataWithData:
                                UIImagePNGRepresentation(screenShot)];
    UIImage *image=[UIImage imageWithData:imageData];
    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
}

[NSTimer scheduledTimerWithTimeInterval:0.1 target:self 
          selector:@selector(saveImageInPhotoAlbum) 
    userInfo:nil repeats:NO];


// include QuartzCore Framework 
// #import <QuartzCore/QuartzCore.h>

No comments:

Create a list in SwiftUI with sticky section headers

 Sample Code import SwiftUI struct ContentView : View {     @State var isCustomViewControllerDisplayed = false     @State private va...