Darkening a UIView

Posted by igul222 on Stack Overflow See other posts from Stack Overflow or by igul222
Published on 2010-04-16T01:07:42Z Indexed on 2010/04/16 1:13 UTC
Read the original article Hit count: 498

Filed under:
|
|
|

I'd like to "darken" a UIView by a certain amount. Right now, I'm doing the darkening like this:

UIView *overlay = [[UIView alloc] initWithFrame:mainView.bounds];
overlay.backgroundColor = [UIColor blackColor];
overlay.alpha = 0.5f;
[mainView addSubview:overlay];

Unfortunately, this also adds a semi-transparent black overlay to parts of mainView that are transparent. Is there any way to only darken the non-transparent sections?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uiview