lucgian841
lucgian841

Reputation: 2002

Create a transparent UIView with some information in it

In my app I take a picture then I add on this picture weather forecast and position with some UILabels and some UIImageviews. For now I'm getting picture like this:

enter image description here

But I will create something like the following picture:

enter image description here

Does anyone ions how to do a stuff like the second picture? In other word I've to create a transparent section in which I will show the weather forecast, the position and the date. I hope you can help me

Upvotes: 2

Views: 86

Answers (5)

Archit
Archit

Reputation: 1

Maybe you should try changing the background colour of the view. For example make it black and add an alpha value.

For Example:

[yourview setBackgroungColor = [UIColor colorWithRed:<#(CGFloat)#> green:<#(CGFloat)#> blue:<#(CGFloat)#> alpha:<#(CGFloat)#>]];

Upvotes: 0

Retro
Retro

Reputation: 4005

You can add the view layer for achieving this kinda effect in your view controller like i would do if i have to

enter image description here

Upvotes: 0

Schrodingrrr
Schrodingrrr

Reputation: 4271

If you simply want to set a backgroundColor with transparency (not translucency), you assign background color like this:

yourView.backgroundColor = [[UIColor darkGrayColor] colorWithAlphaComponent:0.5f];

If this is inside UIImagePickerController, you might want to check out the cameraOverlayView property of UIImagePickerController`.

Upvotes: 0

gran33
gran33

Reputation: 12951

Wherever u set the view, just add this for example:

yourView.backgroundColor = [UIColor darkGrayColor];
yourView.alpha = 0.5;

U can change the background color to whatever u want...

Notice! The alpha will effect also the subviews of yourView.

So u can play with it, with some views with transparent backgrounds above yourView..

Good Luck!

Upvotes: 0

ChintaN -Maddy- Ramani
ChintaN -Maddy- Ramani

Reputation: 5164

You need to create this hierarchy to create view.Set Alpha as you want.enter image description here

Upvotes: 5

Related Questions