Xcode, iOS, iPhone, iPad, Mac OS, Objective C, C, C++, Android, Java.

Tuesday, 4 August 2015

Convert UIView to UIImage. Taking screenshot programatically iOS.

-(UIImage *)convertViewToImage:(UIView*)view
{
    UIGraphicsBeginImageContext(view.bounds.size);//context create a canvas to draw 
    [view drawViewHierarchyInRect: view.bounds afterScreenUpdates:YES];//draws the view hierarchy into the current context
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();//Fetches UIImage from the current context
    UIGraphicsEndImageContext();// Context ends.
 
    return image;
}
Posted by HDDev at 22:49 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: screenshot, UIGraphicsBeginImageContext, UIImage, UIView
Newer Posts Older Posts Home
Subscribe to: Comments (Atom)

Get More

  • ►  2024 (3)
    • ►  September (1)
    • ►  August (2)
  • ►  2023 (2)
    • ►  March (2)
  • ►  2020 (2)
    • ►  January (2)
  • ►  2018 (2)
    • ►  July (1)
    • ►  March (1)
  • ►  2017 (1)
    • ►  March (1)
  • ►  2016 (1)
    • ►  January (1)
  • ▼  2015 (6)
    • ▼  August (1)
      • Convert UIView to UIImage. Taking screenshot progr...
    • ►  July (1)
    • ►  June (1)
    • ►  April (1)
    • ►  March (1)
    • ►  January (1)
  • ►  2014 (14)
    • ►  December (1)
    • ►  November (1)
    • ►  August (2)
    • ►  July (1)
    • ►  June (1)
    • ►  May (1)
    • ►  April (1)
    • ►  March (2)
    • ►  February (1)
    • ►  January (3)
  • ►  2013 (54)
    • ►  December (2)
    • ►  November (1)
    • ►  October (2)
    • ►  September (2)
    • ►  August (6)
    • ►  July (12)
    • ►  June (29)

Contributors

  • HDDev
  • Shivani

iOS

  • Home

Pages

  • Home
Simple theme. Powered by Blogger.