iOS Dim background when a view is shown

animation, ios, objective-c, uiview

Solution

Lay a UIView over the background, set its background to `[UIColor blackColor]` and set its opacity to like 0.6. Then add that UIView to the parent view.

This'll dim out the background AND intercept any taps to background controls.

Problem

In my main view, I do some gesture action causing some new view to be shown. At this time I want to dim the entire background (except this new view) as a good UI practice. In HTML, Javascript it looks like so - How do I get this same effect in iOS ?

Original source