2014-03-31 129 views
1

我想如何在iPhone SDK中應用這種效果?如何在iPhone SDK中實現這種效果?

enter image description here

所以,我有一個形象,並在其頂部的標籤。 我想要將底部部分與圖像混合的效果。 因此,從圖像在視圖的底部結束的地方沒有明確的界限。

請讓我知道。

+1

添加自定義'UIView'用漸變色和低阿爾法在圖像和下面的標籤。 –

回答

0

最簡單的解決方案:添加UIImageView與漸變PNG圖像作爲圖像和標籤之間的子視圖,如果你有恆定的顏色。

如果您需要漸變顏色,您可以添加使用CoreGraphicsCALayer繪製的漸變的子視圖。

如果您需要將圖像與任何背景混合,則可以使用CALayer漸變圖層來遮罩背景圖像圖層。

0

除非你提供任何更多的細節與問候功能和一些代碼你的問題,先看看情況似乎有以下解決方案:

步驟1 設置一個UIImage作爲背景圖像。在你的情況下,這是問題中顯示的那個。

第2步添加一個UILabel作爲UIImage的子視圖並將UILabel的背景設置爲透明。根據您的需求定位標籤,這在您的案例中似乎是最後的選擇。

希望他的幫助!

1

簡單的方法來實現這一目標,以CAGradientLayer

UIView *yourGradientView; // with that label "ENTREES", Add this view as a subview of the background view. 


CAGradientLayer *gradientLayer=[CAGradientLayer layer]; 
[gradientLayer setFrame:[yourGradientView bounds]]; 
[gradientLayer setColors:@[(id)[UIColor clearColor].CGColor, (id)[[UIColor whiteColor] colorWithAlphaComponent:0.7f].CGColor]]; 
[gradientLayer setLocations:@[[NSNumber numberWithFloat:0.50f], [NSNumber numberWithFloat:1.0f]]]; 
[[yourGradientView layer] insertSublayer:gradientLayer atIndex:0];