iPhone – Howe Capture UiView Top UiView

I have UIView showing Graph.. Now I need to capture it to UI Image and I searched it with google and got the following code. But if I use it in my code it doesn’t work . Even if I use the breakpoint compiler, I can’t achieve this. I use it in my UIView. Am I going wrong?

+ (UIImage *) imageWithView:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return img;
}

You can use the following methods to intercept iPhone apps Screenshot of any view of the program or the entire screen

- (UIImage *)captureView {

//hide controls if needed
CGRect rect = [self.view bounds];

UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext: context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;

}

and call it Howl…

UIImage *tempImageSave=[self captureView];

You You can also save this image with the ripple line of this album..

UIImageWriteToSavedPhotosAlbum(tempImageSave,nil,nil,nil);

You can also use this Save this image in the corrugated line of the document directory.

NSData *imageData = UIImagePNGRepresentation(tempImageSave);
NSFileManager *fileMan = [NSFileManager defaultManager];
< br />NSString *fileName = [NSString stringWithFormat:@"%d.png",1];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex :0];
NSString *pdfFileName = [documentsDirectory stringByAppendingPathComponent:fileName];
[fileMan createFileAtPath:pdfFileName contents:imageData attributes:nil];

If the view contains layer images or For some graphics-related data, use the following methods.

-(UIImage *)convertViewToImage:(UIView *)viewTemp
{
UIGraphicsBeginImageContext(viewTemp. bounds.size);
[viewTemp drawViewHierarchyInRect:viewTemp.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageC ontext();
UIGraphicsEndImageContext();

return image;

}

and use the following methods.

UIImage *tempImageSave = [self convertViewToImage:yourView];

I hope this helps you.

Me There is UIView showing Graph.. Now I need to capture it to UI Image and I searched it with google and got the following code. But if I use it in my code it doesn’t work. Even if I use breakpoint compiler, it can’t reach This. I use it in my UIView. Am I wrong?

+ (UIImage *) imageWithView:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return img;
}

You can use the following methods to take a screenshot of any view of the iPhone app or the entire screen

- (UIImage *)captureView {

//hide controls if needed
CGRect rect = [self.view bounds];

UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext ();
UIGraphicsEndImageContext();
return img;

}

and call it a bellow…

UIImage *tempImageSave=[self captureView];

You can also save this image with the ripple line of this album..

UIImageWriteToSavedPh otosAlbum(tempImageSave,nil,nil,nil);

You can also use the corrugated line of this document directory to save this image.

NSData *imageData = UIImagePNGRepresentation(tempImageSave);
NSFileManager *fileMan = [NSFileManager defaultManager];

NSString *fileName = [NSString stringWithFormat:@"%d.png",1];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *pdfFileName = [documentsDirectory stringByAppendingPathComponent:fileName];
[fileMan createFileAtPath: pdfFileName contents:imageData attributes:nil];

If the view contains layer images or some graphics-related data, use the following methods.

-( UIImage *)convertViewToImage:(UIView *)viewTemp
{
UIGraphicsBeginImageContext(viewTemp.bounds.size);
[viewTemp drawViewHierarchyInRect:viewTemp.bounds afterScreenUpdates:YES];
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

retu rn image;

}

And use the following method.

UIImage *tempImageSave = [self convertViewToImage:yourView];< /pre> 

I hope this helps you.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 301 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.