- iOS 13.0+Beta
- Xcode 11.0+Beta
- Mac Catalyst 13.0+Beta
This sample guides you through several types of customizations that you can do in your iOS app. The sample uses a split view controller architecture for navigating UIKit views and controls. The primary view controller (
Master) shows the available views and controls. Selecting one shows the secondary view controller associated with it.
The name of each secondary view controller reflects its target item. For example, the
Alert class shows how to use a
UIAlert object. The only exceptions to this rule are
UIToolbar; these APIs are demonstrated in multiple view controllers to explain how their controls function and how to customize them. To demonstrate how to manage the complexity of your storyboards, all view controllers are hosted in a separate storyboard and loaded when needed.
This sample demonstrates the following views and controls (several of which are referenced in the sections below):
Add Accessibility Support to Your Views
VoiceOver and other system accessibility technologies use the information provided by your views and controls to help all users navigate your content. UIKit views include default accessibility support, but you can improve the user experience by providing custom accessibility information.
In this UIKitCatalog sample, several view controllers configure the
accessibility properties of their associated view. Picker view columns don’t have labels, so the picker view asks its delegate for the corresponding accessibility information:
Display a Custom Alert
Alert demonstrates several techniques for displaying modal alerts and action sheets from your interface. The configuration process is similar for all alerts:
Determine the message you want to display in the alert.
Create and configure a
Add handlers for actions that the user may take.
Present the alert controller.
show function uses the
NSLocalized function to retrieve the alert messages in the user’s preferred language. This function uses those strings to create and configure the
UIAlert object. Although the button in the alert has the title OK, the sample uses a cancel action to ensure that the alert controller applies the proper styling to the button:
Customize the Appearance of Sliders
This sample demonstrates different ways to display a
UISlider, a control used to select a single value from a continuous range of values. You customize the appearance of a slider by assigning stretchable images for left-side tracking, right-side tracking, and the thumb. In this example, the track image is stretchable and is one pixel wide. Make the track images wider to provide rounded corners, but be sure to set these images’
cap property to allow for them.
configure function sets up a custom slider:
Add a Search Bar to Your Interface
UISearch for receiving search-related information from the user. There are various ways to customize the look of the search bar:
Add a cancel button.
Add a bookmark button.
Set the bookmark image, both normal and highlighted states.
Change the tint color that applies to key elements in the search bar.
Set the search bar’s background image.
configure function sets up a custom search bar:
Customize the Appearance of Toolbars
This sample shows how to customize a
UIToolbar, a specialized view that displays one or more buttons along the bottom edge of your interface. Customize a toolbar by determining its bar style (black or default), translucency, tint color, and background color.
view function in
Custom sets up a tinted tool bar:
Custom demonstrates further customization by changing the toolbar’s background image:
Add a Page Control Interface
UIPage to structure your app’s user interface. A page control is a specialized control that displays a horizontal series of dots, each of which corresponds to a page in the app’s document or other data-model entity. You customize a page control by setting its tint color for all the page indicator dots, and for the current page indicator dot.
configure function sets up a customized page control: