title: Capture UIView and Save as Image
body: <p>First of i Add the <code>UILable</code> on <code>UIImageView</code> and then after i screenshot the <code>UIView</code>, the image not proper capture the <code>UIView</code> Frame i also attach the image  url.</p>
  
  <p><img src="https://i.stack.imgur.com/ckVSg.png" alt="enter image description here"></p>
  
  <p><a href="https://postimg.cc/image/fitpypmip/" rel="nofollow noreferrer">1) Original Image Link:</a></p>
  
  <p><img src="https://i.stack.imgur.com/1gWyJ.png" alt="enter image description here"></p>
  
  <p><a href="https://postimg.cc/image/fwn8svecd/" rel="nofollow noreferrer">2) After Capture the image Link:</a> </p>
  
  <p>Code:</p>
  
  <pre><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];
  </code></pre>