Pressure Sensitive Gestures with 3D Touch and iOS 9



ios9-3dtouch With the release of iOS 9, Apple is enabling developers to add pressure sensitive gestures to their iOS apps running on iPhone 6s and iPhone 6s Plus devices. Using the new 3D Touch APIs, an iPhone app is now able to not only tell that the user is touching the device’s screen, but is also able to sense how much pressure the user is exerting and respond to different levels of pressure.

3D Touch enables new levels of interaction and brings new functionality to iOS apps in the following ways.

Quick Actions

Using 3D Touch and Quick Actions, the developer can add common, quick, and easy to access shortcuts to functions in an iOS app from the Home screen icon on the iOS device.

You can think of Quick Actions like the contextual menus that can be popped-up when a user right-clicks on an item in a desktop app. Use Quick Actions to provide shortcuts to the most common functions or features of the app.

Defining Static Quick Actions

If one or more of the Quick Actions required by an app are static and do not need to change, the developer can define them in the app’s Info.plist file.

Creating Dynamic Quick Action Items

In addition to defining static Quick Action items, the developer can create dynamic on-the-fly Quick Actions to the FinishedLaunching method of the AppDelegate.cs file in our Quick Action sample.

Peek and Pop

3D Touch provides new ways for a user to interact with information within an app quicker than ever, without having to navigate from their current location.

For example, if an app is displaying a table of messages, the user can press hard on on an item to preview its content in an overlay view (which Apple refers to as a Peek). If the user presses harder, they will enter the regular message view (which is referred to as Pop-ping into the view). The following code is from our peek and pop sample:

Pressure Sensitivity

By using the new properties of the UITouch class an app can measure the amount of pressure the user is applying to the iOS device’s screen and use this information in its user interface. For example, making a brush stroke more translucent or opaque based on the amount of pressure.

As a result of 3D Touch, if a Xamarin.iOS app is running on iOS 9 (or greater) and the iOS device is capable of supporting 3D Touch, changes in pressure will cause the TouchesMoved event to be raised. When monitoring the TouchesMoved event of a UIView, an app can get the current pressure that the user is applying to the screen.

Wrapping Up

3D Touch enables new functionality and convenience features in a Xamarin.iOS app, from Quick Actions to access an app’s most common functions or features to quick and easy access to information details using Peek and Pop, and finally Pressure Sensitivity for drawing or game apps.

You can learn more about 3D Touch and download sample projects from the iOS 9 Samples Gallery today.

Kevin Mullins

Follow Kevin   

No Comments.