views:

69

answers:

2

Hello everyone,

I'm trying to have a modular uiview that will be placed on top of another view. The modular view has an alpha value of 0.5, and appears in the middle of the main view.

Now, I would like for text to be rendered on that modular UIView. However, whenever I:

[modularView addSubview:text]

it looks all hazy.

How can I make the text tack sharp, but keep the alpha of its parent view at 0.5?

Thanks!

+1  A: 

I'm doing the same on a project i'm working on, my "modalview" is on top of a fullscreen image.

My "modalview" has alpha 1.0 and the background color is black with 50% opacity.

Then the text is white, with default highlight and a dark shadow with 1.0 h and v-offset.

Hope it helps...

PS: make sure you're adding the text in front of the "modalview", not behind it ;)

Adri
+1  A: 

Set the alpha for the background color rather than for the whole view:

[modularView setBackgroundColor:[UIColor colorWithRed:0.0 
                                         green:0.0 
                                          blue:0.0 
                                         alpha:0.5]];

This will allow any subviews to retain full opacity. The color in my code is black. Just set the RGB values for whatever color you're wanting.

You could also just use a UILabel instead of a UIView and set it's background the same way. Then you don't need to add a subview--though I'm not sure what else you have in your modularView view.

Matt Long