I'm working in iOS 6
. Is there an easy way to darken (i.e. add a darker tint) to everything on a UIViewController
screen except for a few select UIImageViews
?
Like, the goal is to make the non-darkened images stand out. The user clearly knows those are the only valid or selectable UIImageViews
to tap -- and when the user taps a valid UIImageView
, the screen would return to normal.
Just to clarify, I don't just want to vanish everything else, just darken it, like adding a transparent 0.5 alpha layer.
I looked here: Darken view as if disabled and it seems very relevant, except I'm not working on a single UIImageView
, but a UIViewController
that has UIImageViews
as subviews. And even if I run the masking code on every subview in my superview, it still wouldn't cover the entire screen, I think.
Thanks for your help.
UIView *blackView = [[UIView alloc] initWithFrame:someFrame];
blackView.backgroundColor = [UIColor blackColor];
blackView.alpha = 0.5;
[self.view addSubview:blackView];
for (UIImageView *imageViewToShow in self.view.subviews) {
[self.view bringSubviewToFront:imageViewToShow];
}
If this causes problems, you might consider redesigning your code to keep the images inside a containerView of sorts. Then you can simply use [self.view insertSubview:blackView belowSubview:containerView];
instead. Then you can manipulate the alpha and hidden aspects of the blackView whenever you feel like it. Heck, if your design warrants it you might add the blackView before any images have been created omitting the meed of the container view as well...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With