Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
UIPageControl with square dots having custom size (hack).
import UIKit
class QuadPageControl: UIPageControl {
override func layoutSubviews() {
super.layoutSubviews()
guard !subviews.isEmpty else { return }
let spacing: CGFloat = 3
let width: CGFloat = 15
let height = spacing
var total: CGFloat = 0
for view in subviews {
view.layer.cornerRadius = 0
view.frame = CGRect(x: total, y: frame.size.height / 2 - height / 2, width: width, height: height)
total += width + spacing
}
total -= spacing
frame.origin.x = frame.origin.x + frame.size.width / 2 - total / 2
frame.size.width = total
}
}
@Hamza9512

This comment has been minimized.

Copy link

Hamza9512 commented May 6, 2019

Hi. I wonder if it's possible to make something like this? Thank for the QuadPageControl it helps a lot.
Screen Shot 2019-05-06 at 20 15 59

@nitinnitin12

This comment has been minimized.

Copy link

nitinnitin12 commented Jul 8, 2019

Hi Michał Mosiołek, thank you. This helped me alot.

@JorgeSainz

This comment has been minimized.

Copy link

JorgeSainz commented Dec 6, 2019

Very usefull to have a quick customization of the shape!
Thanks you!

@pikselmutfak

This comment has been minimized.

Copy link

pikselmutfak commented Mar 22, 2020

not working in iOS13.
whole layout under UIViewController.view gets broken.
only works ios < 13
any ideas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.