2012-08-02 43 views
0

我正在創建一個iOS應用程序,我在其中添加了一個簡單的UIImage。我想在圖像中添加透明效果以顯示該主圖像背後的其他圖像。告訴我如何才能達到這個效果?透明UIImage

注意:我不想更改圖像的不透明度/ alpha。

+6

[你有什麼試過?](http://whathaveyoutried.com) – 2012-08-02 07:05:30

回答

8

,一種α的變化是如何改變透明度的層。除此之外,您可能希望直接在視圖級別上對此進行更改,而不是直接對UIImage進行更改。 E.x:

[myImageView setImage:[UIImage [email protected]"myImage.png"]]; 
[myImageView setAlpha:0.7f]; 
2

使用圖像的PNG格式與它alpha通道:alpha通道是告訴每個像素多少透明是

2

這個怎麼樣:

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; 

但一定要實例化的ImageView,物業再合成。