2

1つのビューに2つの画像を表示する必要があります。これまでは1つの画像しか表示していませんでしたが、1つのビューに2つの画像を表示するにはどうすればよいですか?iPhoneで可能ですか?もしそうなら、私に方法を教えてもらえますか?

注:両方の画像を同時に表示する必要があります。

4

6 に答える 6

6

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];
于 2013-02-05T08:09:08.757 に答える
2

のいずれかを使用できます - の 2 つのインスタンスをUIImageView必要に応じてレイアウトします。- またはサブクラス化し、オーバーライドしてUIView2 を描画しますUIImagedrawInRect:

于 2013-02-04T09:33:22.563 に答える
2
- (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];
}
于 2013-02-04T09:38:36.183 に答える