meetpd
meetpd

Reputation: 9219

How to achieve this effect in iPhone SDK?

I would like to how can I apply this effect in iPhone SDK?

enter image description here

So, I have an image and a label on top of it. I want to have the effect in which the bottom portion kind of blends in with the image. So that there is no clear demarcation from where the image ends at the bottom portion of the view.

Please let me know.

Upvotes: 1

Views: 263

Answers (3)

Tapas Pal
Tapas Pal

Reputation: 7207

Easy way to achieve this to 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];

Upvotes: 1

madLokesh
madLokesh

Reputation: 1878

Unless you provide any more details to your question with regards to functionality and some code, the first look instance seems to have the following solution:

Step 1 Set a UIImage as a background image. In your case it is the one shown in the question.

Step 2 add a UILabel as a subview of UIImage and set the background of UILabel to be transparent. Position the label as per your needs which in your case seems to be the bootom left.

Hope his helps !!!

Upvotes: 0

Lukas Kukacka
Lukas Kukacka

Reputation: 7704

Easiest solution: Add UIImageView with gradient PNG image as a subview between the image and label if you have the constant color.

If you need variable color of the gradient, you can either add a subview with the gradient drawn using CoreGraphics or CALayer.

If you need the image to blend with any background, you can mask the background image layer with CALayer gradient layer.

Upvotes: 0

Related Questions