Permalink
Browse files

Add UIView category method for to get a snapshot image.

  • Loading branch information...
1 parent 1eb7478 commit 65fc59f3242e7df015c12ae102da1d01c165ea91 @devinross committed Jul 17, 2014
Showing with 12 additions and 1 deletion.
  1. +3 −0 src/TapkuLibrary/UIView+TKCategory.h
  2. +9 −1 src/TapkuLibrary/UIView+TKCategory.m
@@ -44,4 +44,7 @@
/** Rounds of views frame coordinates to the nearest integer. */
- (void) roundOffFrame;
+
+- (UIImage*) snapshotImageAfterScreenUpdates:(BOOL)updates;
+
@end
@@ -46,7 +46,15 @@ - (void) roundOffFrame{
-
+- (UIImage*) snapshotImageAfterScreenUpdates:(BOOL)updates{
+
+ UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, [UIScreen mainScreen].scale);
+ [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:updates];
+ UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
+ UIGraphicsEndImageContext();
+
+ return img;
+}

0 comments on commit 65fc59f

Please sign in to comment.