小编我今天刚好弄到一个直播里面需要截屏的方法,百度了很久都是界面截屏,当开启相机就会白底。不多说直接上代码。。。
-(UIImage*)captureView:(UIView *)theView
{
UIGraphicsBeginImageContext(CGSizeMake(theView.size.width, theView.size.height));
[theView drawViewHierarchyInRect:CGRectMake(0, 0,theView.size.width, theView.size.height) afterScreenUpdates:NO];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
网友评论