IT虾米网

iOS捕捉屏幕截图

qq123 2018年06月23日 手机开发 1200 0
+ (UIImage *) imageFromView: (UIView *) theView 
{ 
    // Draw a view’s contents into an image context 
    UIGraphicsBeginImageContext(theView.frame.size); 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    [theView.layer renderInContext:context]; 
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    return theImage; 
}

评论关闭
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!