我想从diffent imageview中添加两个图像,使它们看起来像是两个图像相互重叠,当用户显示图像时,它会显示两个图像,当用户通过侧面移动它们的iphone时,它会显示一个图像(只有一个图像)显示和其他人消失)像全息图。
请帮助我,对我来说非常重要。 谢谢...... !!
答案 0 :(得分:3)
由于您想要显示像全息图这样的图像,然后只显示一个图像,可能的方法是:
这可能会有所帮助。
答案 1 :(得分:2)
尝试使用此代码合并两个图像
UIGraphicsBeginImageContext(firstImage.size);
[firstImage drawAtPoint:CGPointMake(0,0)];
[secondImage drawAtPoint:CGPointMake(0,0)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
答案 2 :(得分:1)
您可以使用此代码。
+ (UIImage*)mergeImage:(UIImage*)first withImage:(UIImage*)second
{
// get size of the first image
CGImageRef firstImageRef = first.CGImage;
CGFloat firstWidth = CGImageGetWidth(firstImageRef);
CGFloat firstHeight = CGImageGetHeight(firstImageRef);
// get size of the second image
CGImageRef secondImageRef = second.CGImage;
CGFloat secondWidth = CGImageGetWidth(secondImageRef);
CGFloat secondHeight = CGImageGetHeight(secondImageRef);
// build merged size
CGSize mergedSize = CGSizeMake(MAX(firstWidth, secondWidth), MAX(firstHeight, secondHeight));
// capture image context ref
UIGraphicsBeginImageContext(mergedSize);
//Draw images onto the context
[first drawInRect:CGRectMake(0, 0, firstWidth, firstHeight)];
[second drawInRect:CGRectMake(0, 0, secondWidth, secondHeight)];
// assign context to new UIImage
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
// end context
UIGraphicsEndImageContext();
return newImage;
}
或试试这个link。