How to blend two images by changing alfa of only one image so that the upper image will be slightly transparent and the above image will be displayed as it is drawn on the background image.
Asked
Active
Viewed 1,459 times
0
-
Possible duplicate of http://stackoverflow.com/questions/1309757/blend-two-uiimages – waldrumpus Sep 21 '12 at 09:14
1 Answers
0
You can do it through imageView alpha property
imageView.alpha = 0.0f;
Detailed code:
UIImage *bottomImage = [UIImage imageNamed:@"bottomImage.png"];
UIImage *topImage = [UIImage imageNamed:@"topImage.png"];
CGSize newSize = CGSizeMake(width, height);
UIGraphicsBeginImageContext( newSize );
// Use existing opacity as is
[bottomImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
// Apply supplied opacity
[topImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height) blendMode:kCGBlendModeNormal alpha:0.8];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
see more details here

Community
- 1
- 1

Shamsudheen TK
- 30,739
- 9
- 69
- 102
-
I have the above code but when i change the alpha value background image alpha also changes. – Prerna chavan Sep 21 '12 at 09:21