//獲取屏幕截屏方法
- (UIImage *)captureWithFrame:()
{
// 創(chuàng)建一個context
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
//把當(dāng)前的全部畫面導(dǎo)入到棧頂context中并進行渲染
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
// 從當(dāng)前context中創(chuàng)建一個新圖片
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
// 使當(dāng)前的context出堆棧
UIGraphicsEndImageContext();
return img;
}
版權(quán)聲明:出自MajorLMJ技術(shù)博客的原創(chuàng)作品 ,轉(zhuǎn)載時必須注明出處及相應(yīng)鏈接!