scrollView截取指定区域的图片
把scrollView放到一个容器里面,再截图就可以了
scrollview放到容器:
UIView *lunboCarrier = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.headerLevelView.frame) + widthWith6(24), Main_Screen_Width, widthWith6(170))]; [self.headerV addSubview:lunboCarrier]; lunboCarrier.backgroundColor = [UIColor clearColor]; _lunboView = [[GXLunBoView alloc] initWithFrame:lunboCarrier.bounds]; // GXLunBoView是轮播图
截图:
+(UIImage*)imageFromView:(UIView *)theView atFrame:(CGRect)rect { UIGraphicsBeginImageContext(theView.frame.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); UIRectClip(rect); [theView.layer renderInContext:context]; UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return theImage; }