SceneDelegate For Multi-Window Support

iPadOS brings multi-window support in the same app. Now when you create a new Xcode you’ll see a SceneDelegate file. This is for managing individual scenes (windows). So the AppDelegate’s UI related responsibilities are now taken over by SceneDelegate.

Lifecycle methods like applicationDidBecomeActive in the AppDelegate no longer work. Instead, SceneDelegate methods like sceneDidBecomeActive gets triggered now.

To get back the old behavior, remove the Application Scene Manifest entry from info.plist file and add the window property back in the AppDelegate .

New Context Menus

Context Menus are a replacement for the Peek and Pop which worked on devices with 3D touch only.

Context menus, on the other hand, work on all devices. We can set menus, submenus as well as Preview the Target View Controller.

The menu is visible just above or below the preview.

New Context Menu. Image From Apple Docs

To implement a context menu on collection/table view there’s a newly added function in the delegate that you need to override.

For collection view it is:

func collectionView(_ collectionView: UICollectionView,

contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration?

We can define our own UIMenu and assign actions to them.

To open the target view controller from the preview we need to implement the method:

func collectionView(_ collectionView: UICollectionView,

willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration,

animator: UIContextMenuInteractionCommitAnimating)

Dark Mode And Dynamic Colors

We can customize the user interface to dark mode in iOS 13 using the userInterfaceStyle property, part of traitCollection .

Dynamic colors are now available and they can be adopted for dark or light mode. We can even assign our own set of color or dynamic image for lightAppearance and darkAppearance .

In order to opt-out of dark mode or lock the appearance to just one type we set the UIUserInterfaceStyle to Light/Dark in the info.plist file.

Sign In With Apple

Screenshot from Xcode

Starting iOS 13, we can integrate Sign In With Apple button in our applications. It’s a secure and easy way to sign in and requires only the username and email address.

Moreover, the user can choose to hide their email address in the app.

To add a Sign In With Apple button in your app, just import AuthenticationServices and add the following code in your ViewController:

let button = ASAuthorizationAppleIDButton() button.addTarget(self, action: #selector(handleAuthorization), for: .touchUpInside)

self.view.addSubview(button)

You can then handle the authorization and verification part on the button click. Please note that this requires Xcode 11.