OC代码如下

 

- (UIImage *)captureScreen:(UIView *)mView size:(CGSize)mSize {

//    Creates a bitmap-based graphics context and makes it the current context

//创建一个位图,并成为当前的背景

    UIGraphicsBeginImageContext(mSize);

//    Renders the receiver and its sublayers into the specified context

//渲染给子layer提供一个特定的背景

    [mView.layer renderInContext:UIGraphicsGetCurrentContext()];

//    Returns an image based on the contents of the current bitmap-based graphics context

//返回一个当前背景下的位图

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

//    Removes the current bitmap-based graphics context from the top of the stack

//讲当前位图从堆中移除

    UIGraphicsEndImageContext();

    return image;

}