InfinityPageControl

open class InfinityPageControl : UIControl

A infinite page control that shrinks/expands its dots.

Subspec: Views/InfinityPageControl

private lazy var pageControl = InfinityPageControl(activeDotImage: #imageLiteral(resourceName: "active-dot"),
                                                   inactiveDotImage: #imageLiteral(resourceName: "inactive-dot"))

pageControl.numberOfPages = dataSources.count
pageControl.currentPage = currentPage

The InfinityPageControl allows a infinitely scrollable page control view similar to the instagram style of page control. When initializing the active and inactive images can be set. The number of pages and the current page can be updated post init and will resize upon setting it. When constrainting the page control you can set the height of the view, however please do not set the width of the view since this might cause constraint issues.

  • Number of pages.

    Declaration

    Swift

    public var numberOfPages: Int { get set }
  • Current page of the page control.

    Declaration

    Swift

    public var currentPage: Int { get set }
  • Page control’s intrinsic content size.

    Declaration

    Swift

    open override var intrinsicContentSize: CGSize { get }
  • Maximium dot limit.

    Declaration

    Swift

    static let dotLimit: Int
  • Offset space in between the dots.

    Declaration

    Swift

    static let dotOffset: Int
  • StackView that contains the dots.

    Declaration

    Swift

    private var stackView: UIStackView
  • ScrollView that enables the pagination of the dots.

    Declaration

    Swift

    private var scrollView: UIScrollView
  • Array of the paging dots.

    Declaration

    Swift

    private var dots: [PagingDot]
  • Active dot image.

    Declaration

    Swift

    private let activeDotImage: UIImage
  • Inactive dot image.

    Declaration

    Swift

    private let inactiveDotImage: UIImage
  • Default initializer of the page control view.

    Declaration

    Swift

    public init(activeDotImage: UIImage, inactiveDotImage: UIImage)

    Parameters

    activeDotImage

    Active dot image.

    inactiveDotImage

    Inactive dot image.

  • Required initializer for storyboards.

    Declaration

    Swift

    public required init?(coder aDecoder: NSCoder)

    Parameters

    aDecoder

    Decoder.

  • Resets the paging dots to the original state.

    Declaration

    Swift

    func resetPagingDots()
  • Removes all paging dots from the view.

    Declaration

    Swift

    func removePagingDots()
  • Adds the paging dots based on the number of pages.

    Declaration

    Swift

    func addPagingDots()
  • Updates the dots given a direction.

    Declaration

    Swift

    func updateDots(direction: PageControlDirection)

    Parameters

    direction

    Direction of the page control.

  • Animates the dots when the current page is updated.

    Declaration

    Swift

    func animateDots()
  • Updates the dots in the stack view with the given parameters.

    Declaration

    Swift

    func updateStackView(with oldState: PagingDotState,
                         view: PagingDot,
                         direction: PageControlDirection)

    Parameters

    oldState

    Old state of the paging dot.

    view

    PagingDot to update.

    direction

    Direction of the page control.

  • Default state of the paging dot based on the index provided.

    Declaration

    Swift

    private func defaultState(for index: Int) -> PagingDotState

    Parameters

    index

    Index of the desired paging dot.

    Return Value

    The state of the paging dot.

  • Sets up the view to the default state on initialization.

    Declaration

    Swift

    func setup()
  • Sets up the stack view by adding it to the view and constraining it.

    Declaration

    Swift

    func setupStackView()
  • Configures the stack view properties.

    Declaration

    Swift

    func configureStackView()