An object that provides a standard interface for browsing the web.


The view controller includes Safari features such as Reader, AutoFill, Fraudulent Website Detection, and content blocking. It shares cookies and other website data with Safari. The user's activity and interaction with SFSafariViewController are not visible to your app, which cannot access AutoFill data, browsing history, or website data. You do not need to secure data between your app and Safari.

UI features include the following:

  • A read-only address field with a security indicator and a Reader button

  • An Action button that invokes an activity view controller offering custom services from your app, and activities, such as messaging, from the system and other extensions

  • A Done button, back and forward navigation buttons, and a button to open the page directly in Safari

  • On devices that support 3D Touch, automatic Peek and Pop for links and detected data

To learn about 3D Touch, see 3D Touch in iOS Human Interface Guidelines and Adopting 3D Touch on iPhone.

Choosing the Best Web Viewing Class

If your app lets users view websites from anywhere on the Internet, use the SFSafariViewController class. If your app customizes, interacts with, or controls the display of web content, use the WKWebView class.

When you adopt SFSafariViewController and a user presses a link to peek at and then pop to the link’s destination, the user views web content from within your app. Tapping Done, the user returns to the view controller that was displayed before the web content was loaded. When you instead use the WKWebView class, Peek and Pop sends the user to Safari by default.


Creating a Safari View Controller

var delegate: SFSafariViewControllerDelegate?

An object that provides behavior for the Safari view controller's Done and Action buttons.

init(url: URL)

Initializes a Safari view controller that loads the specified URL.

init(url: URL, entersReaderIfAvailable: Bool)

Initializes a Safari view controller that will load the specified URL, entering Reader mode if Reader mode is requested and available.

Instance Properties

var preferredBarTintColor: UIColor

The color to tint the background of the navigation bar and the toolbar.

var preferredControlTintColor: UIColor

The color to tint the the control buttons on the navigation bar and the toolbar.