{"action":"closed","issue":{"url":"https://api.github.com/repos/IFTTT/jot/issues/1","labels_url":"https://api.github.com/repos/IFTTT/jot/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/IFTTT/jot/issues/1/comments","events_url":"https://api.github.com/repos/IFTTT/jot/issues/1/events","html_url":"https://github.com/IFTTT/jot/issues/1","id":78396638,"number":1,"title":"Taking Snapshot of View works well when using UIViewContentModeScaleAspectFill","user":{"login":"Knights22","id":6830903,"avatar_url":"https://avatars.githubusercontent.com/u/6830903?v=3","gravatar_id":"","url":"https://api.github.com/users/Knights22","html_url":"https://github.com/Knights22","followers_url":"https://api.github.com/users/Knights22/followers","following_url":"https://api.github.com/users/Knights22/following{/other_user}","gists_url":"https://api.github.com/users/Knights22/gists{/gist_id}","starred_url":"https://api.github.com/users/Knights22/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Knights22/subscriptions","organizations_url":"https://api.github.com/users/Knights22/orgs","repos_url":"https://api.github.com/users/Knights22/repos","events_url":"https://api.github.com/users/Knights22/events{/privacy}","received_events_url":"https://api.github.com/users/Knights22/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/IFTTT/jot/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-20T06:36:00Z","updated_at":"2015-07-30T06:18:32Z","closed_at":"2015-07-30T06:18:32Z","body":"If using UIViewContentModeScaleAspectFill for the image view, the returned image is distorted if it is a smaller image, taking a snapshot of view seems to work well, code below.\r\n\r\n```objectivec\r\n- (void)saveButtonAction\r\n{\r\n    UIImage *drawnImage = [self snapshot:self.view];\r\n    \r\n    [self.jotViewController clearAll];\r\n    \r\n    ALAssetsLibrary *library = [ALAssetsLibrary new];\r\n    [library writeImageToSavedPhotosAlbum:[drawnImage CGImage]\r\n                              orientation:(ALAssetOrientation)[drawnImage imageOrientation]\r\n                          completionBlock:^(NSURL *assetURL, NSError *error){\r\n                              if (error) {\r\n                                  NSLog(@\"Error saving photo: %@\", error.localizedDescription);\r\n                              } else {\r\n                                  NSLog(@\"Saved photo to saved photos album.\");\r\n                              }\r\n                          }];\r\n}\r\n\r\n- (UIImage *)snapshot:(UIView *)view\r\n{\r\n    UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0);\r\n    [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];\r\n    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();\r\n    UIGraphicsEndImageContext();\r\n    \r\n    return image;\r\n}\r\n```"}}