0

2つのローカル画像をオーバーラップさせ、オーバーラップした1つを3番目の画像に表示しようとしています。このコードを使用していますが、シミュレーターには何も表示されません。

- (void)viewDidLoad
{
    [super viewDidLoad];

    image1 = [[UIImage alloc]init];

    image1 = [UIImage imageNamed:@"iphone.png"];

    imageA = [[UIImageView alloc]initWithImage:image1];


    [self merge];

}

-(void)merge
{
  CGSize size = CGSizeMake(320, 480);
    UIGraphicsBeginImageContext(size);

    CGPoint thumbPoint = CGPointMake(0,0);
    imageview.image = imageA.image;
    [imageA.image drawAtPoint:thumbPoint];

    imageB = [[UIImage alloc]init];

    imageB = [UIImage imageNamed:@"Favorites.png"];

    CGPoint starredPoint = CGPointMake(0, 0);
    [imageB drawAtPoint:starredPoint];

    UIImage *imageC = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    imageview.image = imageC;

    [self.view addSubview:imageview];

}

どこを間違えているのかわからない/わからない。

どんな助けでもかなりあります。

4

2 に答える 2

1

マージで以下のコードを除くすべての場所からすべてのコードを削除します。

-(void)merge
{
    CGSize size = CGSizeMake(320, 480);
    UIGraphicsBeginImageContext(size);

    CGPoint point1 = CGPointMake(0,0);
   // The second point has to be some where different than the first point, other wise, the second image will be above the first image, and you wont even know that the two images are there.
    CGPoint point2 = CGPointMake(100,100);

    UIImage *imageOne = [UIImage imageNamed:@"Image1.png"];
    [imageOne drawAtPoint:point1];



    UIImage *imageTwo = [UIImage imageNamed:@"Image2.png"];
  // If you want the above image to have some blending, then you can do some thing like below. 
  //  [imageTwo drawAtPoint:point2 blendMode:kCGBlendModeMultiply alpha:0.5];

    [imageTwo drawAtPoint:point2];


    UIImage *imageC = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectMake(100,100,200,200)];
    iv.image=imageC;

    [self.view addSubview:iv];


}
于 2012-12-06T12:41:37.877 に答える