#Ipad app snap circuits how to#
Later I will show how to adapt the solution to work with the older application-based lifecycle prior to iOS 13.Įdit SceneDelegate.swift to add calls to hide/show the privacy protection window to the sceneWillEnterForeground(_:) and sceneDidEnterBackground(_:) methods. In order to hide the app’s main interface from the iOS App Switcher we need to show our PrivacyProtectionViewController when the scene enters the background and remove it when the scene enters the foreground. Show PrivacyProtectionViewController when Backgrounded The top frame (the slice element in the tuple returned by the method) is assigned to the frame of the privacyLabel and the bottom frame (the remainder element in the tuple) is ignored.
#Ipad app snap circuits code#
The code in viewWillLayoutSubviews calculates the desired height for the label and uses the divided(atDistance:from:) method on CGRect to split the view controller’s view’s bounds into two frames corresponding to the top two thirds and the bottom third. Rather than vertically centre the label I preferred to have the label centred within the top two thirds of the view. I want the text size to adapt with the user’s Dynamic Type settings so configure the font for the Title1 text style and ensure it will automatically adjust if the user change’s their preferred text size. The label contains a simple multi-line message “Content hidden to protect your privacy” in a gray text color.
This is initialised and added to the view when the property is first accessed. Lazy block-based initialisation is used to create a privacyLabel property. Inheriting from UITableViewController is a simple way to get the standard grouped table view background colour (which matches the appearance of Medical ID Record’s other view controllers). Open Xcode and select File->New->Project. At the time of writing, the current released version of Xcode is 11.3.1. To make use of iOS 13’s scene-based app lifecycle we need to be using at least Xcode 11. The code in this article is in Swift but I have also created an Objective-C version of the sample project with equivalent code changes. I also link to the changes for individual commits so you can view the differences on GitHub. You can use the git command line or a Git client (I use Atlassian’s SourceTree) to switch to specific commits or to examine the code changes for each step.
There are separate commits for each significant step in the process. You can download a completed sample project from GitHub. You should then be able to apply the technique to your own projects. The simplest way to demonstrate the technique is to apply it to a sample iOS project.
In this article I’m going to explain how to hide an app’s interface in the snapshot images shown in the App Switcher. Medical ID Record Hides Sensitive Information in the App Switcher