Views and Controls

Present your content onscreen and define the interactions allowed with that content.

Overview

Views and controls are the visual building blocks of your app’s user interface. Use them to draw and organize your app’s content onscreen.

The screen for creating a reminder includes labels, switches, and many other kinds of views.

Views can host other views. Embedding one view inside another creates a containment relationship between the host view (known as the superview) and the embedded view (known as the subview). View hierarchies make it easier to manage views.

You can also use views to do any of the following:

  • Respond to touches and other events (either directly or in coordination with gesture recognizers).

  • Draw custom content using Core Graphics or UIKit classes.

  • Support drag and drop interactions.

  • Respond to focus changes.

  • Animate the size, position, and appearance attributes of the view.

UIView is the root class for all views and defines their common behavior. UIControl defines additional behaviors that are specific to buttons, switches, and other views designed for user interactions.

For additional information about how to use views and controls, see iOS Human Interface Guidelines.

Topics

View Fundamentals

class UIView

An object that manages the content for a rectangular area on the screen.

Container Views

Organize and present large data sets using container views.

Collection Views

Display nested views using a configurable and highly customizable layout.

Table Views

Display data in a single column of customizable rows.

class UIStackView

A streamlined interface for laying out a collection of views in either a column or a row.

class UIScrollView

A view that allows the scrolling and zooming of its contained views.

Content Views

class UIActivityIndicatorView

A view that shows that a task is in progress.

class UIImageView

An object that displays a single image or a sequence of animated images in your interface.

class UIPickerView

A view that uses a spinning-wheel or slot-machine metaphor to show one or more sets of values.

class UIProgressView

A view that depicts the progress of a task over time.

class UIWebView

A view that embeds web content in your app.

Controls

Gather input and respond to user interactions with controls.

class UIControl

The base class for controls, which are visual elements that convey a specific action or intention in response to user interactions.

class UIButton

A control that executes your custom code in response to user interactions.

class UIDatePicker

A control used for the inputting of date and time values.

class UIPageControl

A 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.

class UISegmentedControl

A horizontal control made of multiple segments, each segment functioning as a discrete button.

class UISlider

A control used to select a single value from a continuous range of values.

class UIStepper

A control used to increment or decrement a value.

class UISwitch

A control that offers a binary choice, such as On/Off.

Text Views

Display and edit text using text views.

class UILabel

A view that displays one or more lines of read-only text, often used in conjunction with controls to describe their intended purpose.

class UITextField

An object that displays an editable text area in your interface.

class UITextView

A scrollable, multiline text region.

Drag and Drop Customization

Extend the standard drag and drop support for text views to include custom types of content.

Visual Effects

class UIVisualEffect

An initializer for visual effect views and blur and vibrancy effect objects.

class UIVisualEffectView

An object that implements some complex visual effects.

class UIVibrancyEffect

An object that amplifies and adjusts the color of the content layered behind a visual effect view.

class UIBlurEffect

An object that applies a blurring effect to the content layered behind a visual effect view.

Bars

Manage the items displayed on navigation bars, tab bars, search bars, and tool bars.

class UIBarItem

An abstract superclass for items that can be added to a bar that appears at the bottom of the screen.

class UIBarButtonItem

A button specialized for placement on a toolbar or tab bar.

class UIBarButtonItemGroup

A set of bar button items on the shortcuts bar above the keyboard on iPad.

class UINavigationBar

Navigational controls displayed in a bar along the top of the screen, usually in conjunction with a navigation controller.

class UISearchBar

A specialized view for receiving search-related information from the user.

class UIToolbar

A control that displays one or more buttons along the bottom edge of your interface.

class UITabBar

A control that displays one or more buttons in a tab bar for selecting between different subtasks, views, or modes in an app.

class UITabBarItem

An item in a tab bar.

protocol UIBarPositioning

A set of methods for defining the ways that bars can be positioned in iOS apps.

protocol UIBarPositioningDelegate

A set of methods that support the positioning of a bar that conforms to the UIBarPositioning protocol.

Appearance Customization

protocol UIAppearance

A collection of methods that gives you access to the appearance proxy for a class.

protocol UIAppearanceContainer

A protocol that a class must adopt to allow appearance customization using the UIAppearance API.

Related Types

struct UIEdgeInsets

The inset distances for views.

struct NSDirectionalEdgeInsets

Edge insets that take language direction into account.

struct UIOffset

Defines a structure that specifies an amount to offset a position.

See Also

User Interface

View Controllers

Manage your interface using view controllers and facilitate navigation around your app's content.

View Layout

Use stack views to lay out the views of your interface automatically. Use Auto Layout when you require precise placement of your views.

Animation and Haptics

Provide feedback to users using view-based animations and haptics.

Windows and Screens

Provide a container for your view hierarchies and other content.