iOS 学习笔记(截屏)

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;

}

iOS 学习笔记(截屏),布布扣,bubuko.com

iOS 学习笔记(截屏)

上一篇:微信之初学者:列表方法之蛮荒物语


下一篇:微信页面开发 第一次总结