The UIPopover​Background​View class provides the background appearance for a popover. This class must be subclassed before it can be used. The implementation of your subclass is responsible for providing the border decoration and arrow for the popover. Subclasses must override all declared properties and methods to provide information about where to lay out the corresponding popover content and arrow. Subclasses must also provide implementations for all methods of the UIPopover​Background​View​Methods protocol.


Subclassing Notes

Your subclass is responsible for providing the background visual styling of the popover, which includes the arrow and appropriately styled border. The popover controller places the actual popover content on top of your background view to finish the popover’s presentation.

The background contents of your view should be based on stretchable images. Because the popover is animated into place (and may require animated transitions), using images is the only way to ensure that the animations are smooth and not jittery. By creating images that can be stretched at appropriate places, your popover can still be resized and adjusted as needed. You can then incorporate those images using UIImage​View subviews or Core Animation layers. When the size of the popover changes (perhaps to accommodate the keyboard), all you have to do is adjust the frame rectangles of your embedded image views.

In addition to providing the background content, your subclass must implement the arrow​Offset and arrow​Direction properties and the methods in the UIPopover​Background​View​Methods protocol. The popover controller uses these methods and properties to get and set information related to your background view. The protocol methods are called once and the values you return should never change. However, the values in the arrow​Offset and arrow​Direction properties can change while your popover is on the screen, so your setter methods should call set​Needs​Layout() when that happens to update the background image views or layers.

To create a stretchable image, use the resizable​Image(with​Cap​Insets:​) method of UIImage.


Accessing the Arrow Metrics

var arrow​Offset:​ CGFloat

The distance (measured in points) from the center of the view to the center line of the arrow.

var arrow​Direction:​ UIPopover​Arrow​Direction

The direction in which the popover arrow is pointing.

Controlling the Popover Appearance

class var wants​Default​Content​Appearance:​ Bool

Determines whether the default content appearance should be used for the popover.