Following a discussion from yesterday during an after work about the snapshot shown when the application goes into the background not being the same as when you just bring the app switcher up and then goes straight back to the app again I decided to put together a simple demo.
Below is a representation of the app life cycle
Most apps present a custom snapshot for your app only when the app is sent to the background which might be okay in most cases. Although let’s say that you are browsing your account statement on the subway and a stranger stands behind you, perhaps you react fast and double-press the home button to bring the app switcher up, only to realize your information is still visible.
So here’s to show how to fix this problem.
In your app delegate, add two UIViews which will be shown when you enter the different states:
These UIViews will be added and removed to the view hierarchy when switching between app states by adding the following code:
And that’s it!
Run your app and demo by either bringing up the app switcher, control center or notification center to see the yellow label for inactive state or send your app to the background and bring the app switcher up to see the red label for background state.