私は異なるイメージビューから2つの画像を追加して、両方の画像が互いに重なるように3Dの外観を与えたいと思っています。ユーザーが画像を表示すると両方の画像が表示され、ユーザーがiPhoneを左右に動かすと1つの画像が表示されます消える)ホログラムのように。
私にとってとても大切な人を助けてください。ありがとうございました......!!
ホログラムのような画像を表示してから、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;
}
または、このリンクを試してください。