1つのビューに2つの画像を表示する必要があります。これまでは1つの画像しか表示していませんでしたが、1つのビューに2つの画像を表示するにはどうすればよいですか?iPhoneで可能ですか?もしそうなら、私に方法を教えてもらえますか?
注:両方の画像を同時に表示する必要があります。
1つのビューに2つの画像を表示する必要があります。これまでは1つの画像しか表示していませんでしたが、1つのビューに2つの画像を表示するにはどうすればよいですか?iPhoneで可能ですか?もしそうなら、私に方法を教えてもらえますか?
注:両方の画像を同時に表示する必要があります。
2 つの画像を重ねたい場合は、このコードを貼り付けてください。
UIImage *a = [ your 1st iamge];
UIImage *b = [ your 2nd iamge];
UIGraphicsBeginImageContext(a.size);
[a drawInRect:CGRectMake(0, 0, a.size.width, a.size.height)];
[b drawInRect:CGRectMake(a.size.width - b.size.width, a.size.height - b.size.height, b.size.width, b.size.height)];
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[YourImageView setImage:result];
のいずれかを使用できます - の 2 つのインスタンスをUIImageView
必要に応じてレイアウトします。- またはサブクラス化し、オーバーライドしてUIView
2 を描画しますUIImage
drawInRect:
- (void)displayImages
{
UIImageView *firstImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourimage"]];
firstImage.frame = CGRectMake(0, 0, 100, 100);
UIImageView *secondImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourimage"]];
secondImage.frame = CGRectMake(100, 0, 100, 100);
[self.view addSubview:firstImage];
[self.view addSubview:secondImage];
}