在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();
网友评论