MDCPageControl

@interface MDCPageControl : UIControl <UIScrollViewDelegate>

A Material page control.

This control is designed to be a drop-in replacement for UIPageControl, but adhering to the Material Design specifications for animation and layout.

The UIControlEventValueChanged control event is sent when the user changes the current page.

UIScrollViewDelegate

In order for the Page Control to respond correctly to scroll events set the scrollView.delegate to your pageControl:

scrollView.delegate = pageControl;

or forward the UIScrollViewDelegate methods:

@c scrollViewDidScroll: @c scrollViewDidEndDecelerating: @c scrollViewDidEndScrollingAnimation:

  • The number of page indicators in the control.

    Negative values are clamped to 0.

    The default value is 0.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSInteger numberOfPages;
  • The current page indicator of the control.

    See setCurrentPage:animated: for animated version.

    Values outside the possible range are clamped within [0, numberOfPages-1].

    The default value is 0.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSInteger currentPage;
  • Sets the current page indicator of the control.

    Declaration

    Objective-C

    - (void)setCurrentPage:(NSInteger)currentPage animated:(BOOL)animated;

    Parameters

    currentPage

    Index of the desired page indicator. Values outside the possible range are clamped within [0, numberOfPages-1].

    animated

    YES the change will be animated; otherwise, NO.

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

    The default value is NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL hidesForSinglePage;
  • The color of the non-current page indicators.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        UIColor *pageIndicatorTintColor;
  • The color of the current page indicator.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        UIColor *currentPageIndicatorTintColor;
  • A Boolean value that controls when the current page is displayed.

    If enabled, user interactions that cause the current page to change will not be visually reflected until -updateCurrentPageDisplay is called.

    The default value is NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL defersCurrentPageDisplay;
  • When this value is set to YES, the indicators will ascend from right to left in an RTL environment.

    Note

    In general, the MDCPageControl’s UIScrollViewDelegate forwarding methods make assumptions about the originating scrollview’s page number based off its contentOffset. When this property is set to YES in an RTL environment, a leftmost content offset will be considered the last page in the scrollview, as opposed to the first.

    The default value is NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        BOOL respectsUserInterfaceLayoutDirection;
  • Updates the page indicator to the current page.

    This method is ignored if defersCurrentPageDisplay is NO.

    Declaration

    Objective-C

    - (void)updateCurrentPageDisplay;
  • Returns the size required to accommodate the given number of pages.

    Declaration

    Objective-C

    + (CGSize)sizeForNumberOfPages:(NSInteger)pageCount;

    Parameters

    pageCount

    The number of pages for which an estimated size should be returned.

  • The owner must call this to inform the control that scrolling has occurred.

    Declaration

    Objective-C

    - (void)scrollViewDidScroll:(nonnull UIScrollView *)scrollView;
  • The owner must call this when the scrollView has ended its deleration.

    Declaration

    Objective-C

    - (void)scrollViewDidEndDecelerating:(nonnull UIScrollView *)scrollView;
  • The owner must call this when the scrollView has ended its scrolling animation.

    Declaration

    Objective-C

    - (void)scrollViewDidEndScrollingAnimation:(nonnull UIScrollView *)scrollView;