ios屏幕截图

-(UIImage *)screenShots:(UIView *)orgView {
    //获取指定View的图片

    UIGraphicsBeginImageContextWithOptions(orgView.bounds.size, NO, 0.0);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [orgView.layer renderInContext:context];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}
- (void)navRightAction:(UIButton *)button{
    
        UIWindow *window = [UIApplication sharedApplication].keyWindow;
        UIImage * img= [self  screenShots:window];
        ELE_MessageDetail * detail = [[ELE_MessageDetail alloc] init];
                                    
                                    
        detail.image = img;
        detail.msgContentType = [NSString stringWithFormat:@"%d",ELEDETAILIMAGE];
        [self shareTheChannelArticleData:detail];

}

你可能感兴趣的:(ios屏幕截图)