标签:
1.截取选中view的图片
//根据size大小创建一个基于位图的图形上下文 CGRect rect =view.frame; UIGraphicsBeginImageContext(rect.size);//根据size大小创建一个基于位图的图形上下文 CGContextRef context = UIGraphicsGetCurrentContext();//获取上下文环境 [view.layer renderInContext:context];//将要截取的view 映射到画布上 UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); //获得图片 UIGraphicsEndImageContext(); imgvc.image = img; [view setHidden:YES];
2.两张图片 合成一张图片
//根据 底层的imageview 大笑 来创建 画布 UIGraphicsBeginImageContext(imgVC_bg.image.size); for (UIImageView *imgvc in array_imageView) { UIImage *img=imgvc.image; //画要添加到imgvc上的img [img drawInRect:CGRectMake(imgvc.frame.origin.x/double_proportion,(imgvc.frame.origin.y-64)/double_proportion,imgvc.frame.size.width/double_proportion,imgvc.frame.size.height/double_proportion)]; [imgvc removeFromSuperview]; } //在画底层imgvc,这样就会把img 添加到imgvc上来。 [imgVC_bg.image drawInRect:CGRectMake(0, 0, imgVC_bg.image.size.width, imgVC_bg.image.size.height)]; //形成新的image CGImageRef NewMergeImg = CGImageCreateWithImageInRect(UIGraphicsGetImageFromCurrentImageContext().CGImage, CGRectMake(0, 0, imgVC_bg.image.size.width, imgVC_bg.image.size.height)); UIGraphicsEndImageContext();
标签:
原文地址:http://www.cnblogs.com/niit-soft-518/p/5473295.html