廢話少嗶嗶,直接上代碼
-(UIImage *)captureScreenForView:(UIView *)currentView {
UIGraphicsBeginImageContext(currentView.frame.size);
[currentView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}