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 学习笔记(截屏),,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。