开发者

overLap Image by another image

开发者 https://www.devze.com 2023-03-25 14:40 出处:网络
I am new to iphone development and making an application which chooses an image from existin开发者_如何学运维g album. After choosing the image I want to put another View on it, or another icon(acne).

I am new to iphone development and making an application which chooses an image from existin开发者_如何学运维g album. After choosing the image I want to put another View on it, or another icon(acne).

Can anyone tell me how to put another image on existing image by code????


Basically if you want to overlay two views/images you can just do it like this:

[self.view addSubview:imageview1];  
[self.view addSubview:imageview2];

imageview2 lays on imageview1, because you added it later.


You want to place UIImageView or UIView on the image ? First you need to create the ImageView with the frame of your choosen image and create another ImageView in the same way as you created first ImageView and add second ImageView to your previous ImageView. if your second ImageView size is equal to the size of first ImageView, you would not be able to see your first ImageView, because it will overlap..


If you want to add a watermark on your image try this code:

UIGraphicsBeginImageContext(CGSizeMake(320, 480));
// This is where we resize captured image
[(UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage] drawInRect:CGRectMake(0, 0, 320, 480)];
// And add the watermark on top of it
[[UIImage imageNamed:@"Watermark.png"] drawAtPoint:CGPointMake(0, 0) blendMode:kCGBlendModeNormal alpha:WATERMARK_ALPHA];
// Save the results directly to the image view property
imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
0

精彩评论

暂无评论...
验证码 换一张
取 消