Darkening everything in the UIViewController view, except for a few UIImageViews

I work in iOS 6 . Is there an easy way to darken (i.e. add a darker shade) to everything on the UIViewController screen, except for a few select UIImageViews ?

For example, the goal is to highlight non-dark images. The user clearly knows that these are the only valid or selectable UIImageViews to click — and when the user deletes the actual UIImageView , the screen will return to normal.

Just to clarify, I do not just want to fade away everything else, it just gets dark, like adding a transparent 0.5 alpha layer.

I looked here: Show the view as disabled , and it seems very relevant, except that I am not working on a single UIImageView , but a UIViewController which has UIImageViews as subzones. And even if I run the masking code in every view in my supervisor, I think it will still not cover the entire screen.

Thank you for your help.

+6
source share
2 answers
 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 the code to save the images inside the containerView. Then you can just use [self.view insertSubview:blackView belowSubview:containerView]; . You can then manipulate the alpha and hidden aspects of blackView whenever you want. Damn it, if your design guarantees it, you can add a black screen before any images are created that will not be displayed in the container view ...

+10
source

You can use:

 [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5]; // This is a transparent black color. 
0
source

Source: https://habr.com/ru/post/957651/


All Articles