page control
  • October 26, 2023

Requirements


  • iOS 9.0+
  • Xcode 7.0+

Installation


CocoaPods:

Add folowing line to Podfile and run ‘pod instal’.

pod ‘Sevruk-PageControl’

Or just drag and drop FoldingCell.swift file to your project

Usage with storyboard


  1. Add a new UIView to storyboard.

  2. Inherit view from PageControl.

  1. In view controller create an outlet to a view from storyboard and you’re ready to go.

Here is code example that uses UIScrollView.

import UIKit
import PageControl

class ViewController: UIViewController, UIScrollViewDelegate {

@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var pageControl: PageControl!

override func viewDidLoad() {
super.viewDidLoad()
scrollView.delegate = self
pageControl.numberOfPages = Int(scrollView.contentSize.width / scrollView.bounds.width)
}

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let page = scrollView.contentOffset.x / scrollView.bounds.width
pageControl.currentPage = page
}
}

Usage without storyboard


  1. Create a PageControl view and add it to your view hierarchy.

let pageControl = PageControl()
addSubview(pageControl)

  1. Setup pageControl with your needs.

pageControl.numberOfPages = 5
pageControl.spacing = 14.0
pageControl.indicatorDiameter = 8.0
pageControl.currentIndicatorDiameter = 12.0
pageControl.indicatorTintColor = .darkGray
pageControl.currentIndicatorTintColor = .green

  1. And update current page when needed.

pageControl.currentPage = 1

GitHub


View Github

#ios #library #materialdesign #swift #ui
YOU MIGHT ALSO LIKE...
exyte

     

camerakit-ios

CameraKit helps you add reliable camera to your app quickly. Our open source camera platform provides consistent capture results, service ...

HybridCamera

[video width="192" height="416" mp4="https://swiftgit.com/wp-content/uploads/2024/12/68747470733a2f2f7261776769742e636f6d2f7374796c656b69742f696d672f6d61737465722f7669645f6564697465645f325f326d622e676966.mp4"][/video]

TakeASelfie

An iOS framework that uses the front camera, detects your face and takes a selfie. This api opens the front ...

iOS-Depth-Sampler

Code examples of Depth APIs in iOS