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?
Here is something to try. I have never used UIRectFillUsingBlendMode.
The view implementing this would have to be set up to composite with only the other views you want to affect. That probably means one parent view that contains this view and all the other views you want to darken.
You can also look into CGContextSetBlendMode.