- (void)SnapShot { if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale); } else { UIGraphicsBeginImageContext(self.view.bounds.size); } [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSData *data = UIImagePNGRepresentation(image); [data writeToFile:@"snapshot.png" options:NSDataWritingWithoutOverwriting error:Nil]; [data writeToFile:@"snapshot.png" atomically:YES]; UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil); } - (void)SnapShot { if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale); else UIGraphicsBeginImageContext(self.view.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSData *data = UIImagePNGRepresentation(image); [data writeToFile:@"snapshot.png" options:NSDataWritingWithoutOverwriting error:Nil]; [data writeToFile:@"snapshot.png" atomically:YES]; UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil); } - (void)SnapShot { if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale); } else { UIGraphicsBeginImageContext(self.view.bounds.size); } [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSData *data = UIImagePNGRepresentation(image); [data writeToFile:@"snapshot.png" options:NSDataWritingWithoutOverwriting error:Nil]; [data writeToFile:@"snapshot.png" atomically:YES]; UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil); } code indent to make it readable + removed unnecessary parts
-(IBAction)SnapShotclicked: (idvoid)sender //SnapShotclicked is an action for UIButton.SnapShot { if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale); else UIGraphicsBeginImageContext(self.view.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSData * data*data = UIImagePNGRepresentation(image); [data writeToFile:@"snapshot.png" options:NSDataWritingWithoutOverwriting error:Nil]; [data writeToFile:@"snapshot.png" atomically:YES]; UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil); } -(IBAction)SnapShotclicked:(id)sender //SnapShotclicked is an action for UIButton. { if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale); else UIGraphicsBeginImageContext(self.view.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSData * data = UIImagePNGRepresentation(image); [data writeToFile:@"snapshot.png" options:NSDataWritingWithoutOverwriting error:Nil]; [data writeToFile:@"snapshot.png" atomically:YES]; UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil); } - (void)SnapShot { if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale); else UIGraphicsBeginImageContext(self.view.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSData *data = UIImagePNGRepresentation(image); [data writeToFile:@"snapshot.png" options:NSDataWritingWithoutOverwriting error:Nil]; [data writeToFile:@"snapshot.png" atomically:YES]; UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil); } -(IBAction)SnapShotclicked:(id)sender //SnapShotclicked is an action for UIButton. { if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale); else UIGraphicsBeginImageContext(self.view.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSData * data = UIImagePNGRepresentation(image); [data writeToFile:@"snapshot.png" options:NSDataWritingWithoutOverwriting error:Nil]; [data writeToFile:@"snapshot.png" atomically:YES]; UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil); } (IBAction)SnapShotclicked:(id)sender //SnapShotclicked is an action for UIButton. { if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale); else UIGraphicsBeginImageContext(self.view.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSData * data = UIImagePNGRepresentation(image); [data writeToFile:@"snapshot.png" options:NSDataWritingWithoutOverwriting error:Nil]; [data writeToFile:@"snapshot.png" atomically:YES]; UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil); } -(IBAction)SnapShotclicked:(id)sender //SnapShotclicked is an action for UIButton. { if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale); else UIGraphicsBeginImageContext(self.view.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSData * data = UIImagePNGRepresentation(image); [data writeToFile:@"snapshot.png" options:NSDataWritingWithoutOverwriting error:Nil]; [data writeToFile:@"snapshot.png" atomically:YES]; UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil); } Loading
lang-objectivec