iOS Developer Library

Developer

UIKit Framework Reference UIPageControl Class Reference

Options
Deployment Target:

On This Page
Language:

UIPageControl

You use the UIPageControl class to create and manage page controls. A page control displays a horizontal series of dots, each of which corresponds to a page in the application’s document (or other data-model entity). The currently viewed page is indicated by a white dot.

For an example of a page control, see the Weather application (with a number of locations configured) or Safari (with a number of tab views set).

When a user taps a page control to move to the next or previous page, the control sends the UIControlEventValueChanged event for handling by the delegate. The delegate can then evaluate the currentPage property to determine the page to display. The page control advances only one page in either direction.

For more information about appearance and behavior configuration, see Page Controls.

Inheritance


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 2.0 and later.
  • The current page, shown by the receiver as a white dot.

    Declaration

    Swift

    var currentPage: Int

    Objective-C

    @property(nonatomic) NSInteger currentPage

    Discussion

    The property value is an integer specifying the current page shown minus one; thus a value of zero (the default) indicates the first page. A page control shows the current page as a white dot. Values outside the possible range are pinned to either 0 or numberOfPages minus 1.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The number of pages the receiver shows (as dots).

    Declaration

    Swift

    var numberOfPages: Int

    Objective-C

    @property(nonatomic) NSInteger numberOfPages

    Discussion

    The value of the property is the number of pages for the page control to show as dots. The default value is 0.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • A Boolean value that controls whether the page control is hidden when there is only one page.

    Declaration

    Swift

    var hidesForSinglePage: Bool

    Objective-C

    @property(nonatomic) BOOL hidesForSinglePage

    Discussion

    Assign a value of YEStrue to hide the page control when there is only one page; assign NOfalse (the default) to show the page control if there is only one page.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The tint color to be used for the page indicator.

    Declaration

    Swift

    var pageIndicatorTintColor: UIColor?

    Objective-C

    @property(nonatomic, retain) UIColor *pageIndicatorTintColor

    Discussion

    The default color is a translucent white for the page indicator dot. The page indicator dot is used for all of the pages not visible on the screen. Assigning a new value to this property does not automatically change the color in the currentPageIndicatorTintColor property because the value for these two properties is not automatically derived from the other. Both properties must be specified independently. Similarly, no alpha is applied to this property for you. It is recommended (but not required) that the color you specify for this parameter contains some transparency–i.e. the alpha value should be less than 1.0.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 6.0 and later.

  • The tint color to be used for the current page indicator.

    Declaration

    Swift

    var currentPageIndicatorTintColor: UIColor?

    Objective-C

    @property(nonatomic, retain) UIColor *currentPageIndicatorTintColor

    Discussion

    The default color is an opaque white for the current page indicator dot. The current page indicator dot is used to indicate the currently visible page. Assigning a new value to this property does not automatically change the color in the pageIndicatorTintColor property because the value for these two properties is not automatically derived from the other. Both properties must be specified independently.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 6.0 and later.

  • A Boolean value that controls when the current page is displayed.

    Declaration

    Swift

    var defersCurrentPageDisplay: Bool

    Objective-C

    @property(nonatomic) BOOL defersCurrentPageDisplay

    Discussion

    Set the value of this property to YEStrue so that, when the user taps the control to go to a new page, the class defers updating the page control until it calls updateCurrentPageDisplay. Set the value to NOfalse (the default) to have the page control updated immediately.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Updates the page indicator to the current page.

    Declaration

    Swift

    func updateCurrentPageDisplay()

    Objective-C

    - (void)updateCurrentPageDisplay

    Discussion

    This method updates the page indicator so that the current page (the white dot) matches the value returned from currentPage. The class ignores this method if the value of defersCurrentPageDisplay is NOfalse. Setting the currentPage value directly updates the indicator immediately.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Returns the size the receiver’s bounds should be to accommodate the given number of pages.

    Declaration

    Swift

    func sizeForNumberOfPages(_ pageCount: Int) -> CGSize

    Objective-C

    - (CGSize)sizeForNumberOfPages:(NSInteger)pageCount

    Parameters

    pageCount

    The number of pages to fit in the receiver’s bounds.

    Return Value

    The minimum size required to display dots for the page count.

    Discussion

    Subclasses that customize the appearance of the page control can use this method to resize the page control when the page count changes.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.