简体   繁体   中英

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.

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. Ex:

[myImageView setImage:[UIImage imageNamed@"myImage.png"]];
[myImageView setAlpha:0.7f];

使用其中带有Alpha通道的png格式的图像:Alpha通道是告诉每个像素多少透明的层

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM