IOS 图片 截取 和 合并

来源:互联网 发布:数据脱敏技术 编辑:程序博客网 时间:2024/05/29 03:26

//当前view 的截图

#    UIGraphicsBeginImageContext(self.view.frame.size); //currentView 当前的view
#    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
#    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
#    UIGraphicsEndImageContext();
#    
#    
#//  图片存入相册
#    UIImageWriteToSavedPhotosAlbum(viewImage,nil,nil,nil);


//合并

-(UIImage *)addImage:(UIImage *)image1 toImage:(UIImage *)image2

{
UIGraphicsBeginImageContext(image2.size);

//Draw image2
[image2 drawInRect:CGRectMake(0, 0, image2.size.width, image2.size.height)];

//Draw image1
[image1 drawInRect:CGRectMake(20, 20, image1.size.width, image1.size.height)];

UIImage *resultImage=UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return resultImage;
}
0 0
原创粉丝点击