Obaid
Obaid

Reputation: 197

Transparent UIImage

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

Answers (3)

Bazinga
Bazinga

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

Mick MacCallum
Mick MacCallum

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

meronix
meronix

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

Related Questions