First of i Add the UILable
on UIImageView
and then after i screenshot the UIView
, the image not proper capture the UIView
Frame i also attach the image url.
2) After Capture the image Link:
Code:
UIGraphicsBeginImageContext(viewImage.frame.size);
[viewImage.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *vwImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *data=UIImagePNGRepresentation(vwImage);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
// NSString *imgName = [NSString stringWithFormat:imagename];
NSString *strPath = [documentsDirectory stringByAppendingPathComponent:imagename];
[data writeToFile:strPath atomically:YES];
You can take the screenshots of any
UIView
or capture anyUIView
and save it as an image with below code.Take snapshot of a UIView
pass your view to this function it will handle everything itself( No need to set bounds or frames)
Try this if you want captured image maintain its original quality.
Try like this,
Swift 3 Version:
you can use the below code to