What’s new in Cocoa Touch (WWDC 2017 Session 201) TL;DR

Here’s a quick recap of most of the “What’s new in Cocoa Touch” session of WWDC 2017 (Session 201). This is all typed live so if something isn’t accurate feel free to correct me :-)


Drag and Drop

The delegate provides data for dragged item, allows customizing the “lift” animation and customize the draggin preview.

Enabling Drop is done by creating a UIDropInteraction and setting its delegate in a similar way. The delegate allows Updating the UI as the drag moves, receive general data on the drop and customize the drop animation.

Many UIKit elements are supported out of the box — TableView, CollectionView, TextView, TextField and WebView.

File Management

a UIDoumentBrowserViewController is the ViewController we can present in our apps. It’s highly customizable and Allows accessing device content, iCloud content and external cloud service.
It’s highly crucial to coordinate file access since we can’t count on our app being the only one to touch certain files/assets. Can be done by using NSFileCoordinator/UIDocument.

UI Refinements

In most cases this can be done almost automatically as the system can handle it autoamtically by setting UINavigationBar.prefersLargeTitle to true.

You could also use UINavigationItem.largeTitleDisplayMode to control separate the large title display mode in a more granular way around levels of navigation.

Enabling the unified search bar is done by setting UINavigationBar.searchBarController.

Usually the top controller in a Navigation Controller/stack would be the only one to use the “Large” style titles, while the inner ones should use the standard small variation.

There is a built in Pull-to-refresh in the Navigation Bar which looks great.

We can’t keep counting on a static height for a Navigation Bar since it might change height for different content types. In most cases this would be handled automatically by the various UINavigation classes. There is a new safeAreaInsets.top property on UIView that we can accurately and reliably use to know the size of the "obscured" area by the navigation bar. There is also a bbottom values. (safeAreaInsets.bottom)

There is also a safeAreaLayoutGuide that you could use as well.

For manual layouts you can manually read safeAreaInsets and subscribe to changes on the size of the Safe Area.

UINavigationController now longer controls the insets values as it is just using the safe insets, so setting manual insets on a Scroll View should no longer have the kinks we are used to.

UIScrollView has new properties called contentInsetAdjustmentBehavior and adjustedContentSize we can use to manually define how the insets behave on UIScrollView.

UITableViewCells now support built in swipe actions on both left and right side using the new UIContextualAction class. It seems similar to how UITableRowAction works but is a bit more refined since you can separately use UISwipeActionsConfiguration to group these UIContextualActions.

There is a new proprety on UITableView called separatorInsetReference that lets you set whether the values of the insets are absolute or "Deltas" e.g. in reference ot the original inset reference the insets would have been at previously.

Swift 4 and Foundation

Archiving Swift native types

Key paths

New block-based KVO instead (!!) using object.obserer(keyPath) { object, change in ... }

Touches related to Status Bar and Control Center

Autolayout and ScrollView

imageView.centerXAnchor.constraints(equalTo: scrollView.contentLayoutGuide.centerXAnchor)

imageView.centerYAnchor.constraints(equalTo: scrollView.contentLayoutGuide.centerYAnchor)

Dynamic Type

Introduced a new UIFontMetrics that you can instantiate for a specific text style, which can handle getting a scaled font based on the standard font which allows using custom fonts for Dynamic Type.

It also allows scaling some arbitrary layout values, meaning it can return a scaled value based on a standardValue you provide, so it actually sort of calculates the correct height size for containers of text participating in Dynamic Type.

It’s now possible to dynamically set the baseline of different labels to eachother based on their Dynamic Type.

lettopAnchor = topLabel.lastBaselineAnchorlet bottomAnchor = bottomLabel.firstBaselineAnchorbottomAnchor.constraintEqualToSystemSpacing(Below: topAnchor)

Password Autofill

Apps can also set an entitlement and another configuration (which are actually also used for Universal Links), which will display an action for your specific app in the autocompletion bar.

Named colors in Asset Catalog


It’s very useful for UITabBars, since it would create accessibility related assets by default without any extra code.

iOS Tech Lead @ Gett 🚕 RxSwift & RxSwiftCommunity core contributor. International speaker and worldwide hackathon winner. Fiddling with tech for a living. 🤓

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store