iOS 学习笔记(截屏)

mac2022-06-30  22

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;

}

转载于:https://www.cnblogs.com/ericiOScnblogs/p/3654931.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)