Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Dim background when a view is shown

Tags:

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 ?

enter image description here

like image 509
Srikar Appalaraju Avatar asked Jul 05 '11 17:07

Srikar Appalaraju


People also ask

How to dim the background of popover on iOS?

Inside the prepareForPopoverPresentation function, set the alpha of the background views to a value less than one. This will dim the background views when the popover is displayed.

How do I dim the background in Swift?

Instead, if you want to dim stuff you need to do it yourself: create a full-screen UIView with a translucent background color (I find 66% black works best) then set its alpha to be 0. When you want things to dim, set the alpha to be 1.


1 Answers

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.

like image 134
Dan Ray Avatar answered Sep 30 '22 18:09

Dan Ray