美文网首页iOS图像处理IOS收藏
iOS开发--两张图片合成

iOS开发--两张图片合成

作者: 寒桥 | 来源:发表于2015-03-19 12:26 被阅读6140次

在iOS开发过程中  有时候需要对几张图片进行合成

两张图片合成

UIImage * image1 = [UIImage imageNamed:@"1.png"];

UIImage * image2 = [UIImage imageNamed:@"2.png"];

CGSize size = self.myImageView.frame.size;

UIGraphicsBeginImageContext(size);

[image1 drawInRect:CGRectMake(0, 0, size.width, size.height)];

[image2 drawInRect:CGRectMake(30, 30, size.width - 60, size.height - 60)];

UIImage *resultingImage =UIGraphicsGetImageFromCurrentImageContext();

self.myImageView.image = resultingImage;

UIGraphicsEndImageContext();

相关文章

网友评论

  • Ego_1973:带有url的图片可以吗?本地图片加到url图片上
  • 07d93406ec39:這個寫法好像很耗內存,有解決的方法嗎?
  • affa198c19d5:谢谢楼主分享!!拜谢!!!

本文标题:iOS开发--两张图片合成

本文链接:https://www.haomeiwen.com/subject/xudwxttx.html