UIImageが二つある状態で重ね合わせを行いたい場合、どうすればいいのだろうか?
複数のUIImageオブジェクトから1つのUIImageオブジェクトを作る
を引用すると次のようになります。(以下、引用)
UIImage *image1 = [UIImage imageNamed:@"image1.png"]; UIImage *image2 = [UIImage imageNamed:@"image2.png"]; UIGraphicsBeginImageContext(CGSizeMake(width, height)); [image1 drawAtPoint:CGPointMake(0, h1)]; [image2 drawAtPoint:CGPointMake(0, h2)]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();上のプログラムだと、それぞれ違う高さに書き出しているが、下のように同じ位置にすれば、image1の上に、image2が重なるようになります。
UIImage *image1 = [UIImage imageNamed:@"image1.png"]; UIImage *image2 = [UIImage imageNamed:@"image2.png"]; UIGraphicsBeginImageContext(CGSizeMake(width, height)); [image1 drawAtPoint:CGPointMake(0, 0)]; [image2 drawAtPoint:CGPointMake(0, 0)]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();これ、すごく便利なので、使い回したいですね。
0 コメント:
コメントを投稿