Reputation: 197
I am creating an iOS application in which I have added a simple UIImage. I want to add the transparency effect in image to show other images behind that main image. Tell me how I can achieve this effect?
Note: I don't want to change the opacity/alpha of image.
Upvotes: 0
Views: 11255
Reputation: 2466
how about this:
self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f,0.0f,1024.0f,768.0f)];
self.imageView.backgroundColor = [UIColor colorWithRed:255 green:255 blue:255 alpha:0.5];
[self.view addSubview:self.imageView];
or set its alpha
imageView.alpha = 0.5;
But be sure to instantiate the imageView, as property then synthesize.
Upvotes: 2
Reputation: 130193
An alpha change is how you alter transparency. In addition to this, you would want to alter this on the view level not on to the UIImage
directly. E.x:
[myImageView setImage:[UIImage imageNamed@"myImage.png"]];
[myImageView setAlpha:0.7f];
Upvotes: 8
Reputation: 6176
use images in png format with alpha channel in it: alpha channel is the layer that tells how many transparent each pixel is
Upvotes: 2