Menu Home

iOS:截图

- (UIImage*)snapshot
{
    UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0);
    [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:NO];
    UIImage *snap = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return snap;
}

– (BOOL)drawViewHierarchyInRect:(CGRect)rect afterScreenUpdates:(BOOL)afterUpdates是在iOS7.0才引入的,所有此方法只适合在iOS7.0及以上系统使用。

Categories: iOS objective-c

Tagged as:

lnmcc