Skip to content

Instantly share code, notes, and snippets.

@sveinhal
Created August 28, 2015 11:11
Show Gist options
  • Save sveinhal/612241ab55bbbe8f042b to your computer and use it in GitHub Desktop.
Save sveinhal/612241ab55bbbe8f042b to your computer and use it in GitHub Desktop.
A page control subclass with customizable dots
import UIKit
@IBDesignable
final class PageControl: UIPageControl {
@IBInspectable var activeImage: UIImage?
@IBInspectable var inactiveImage: UIImage?
private func updateDotImages() {
for (i, subview) in enumerate(subviews) {
if let dot = subview as? UIImageView {
dot.image = (i == currentPage) ? activeImage : inactiveImage
}
}
}
override var currentPage: Int {
didSet {
updateDotImages()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment