Last active
February 12, 2023 16:42
-
-
Save bittz/4ab5fd793d0a18cdbfce18959174858b to your computer and use it in GitHub Desktop.
UIPageControl with square dots having custom size (hack).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
Hi Michał Mosiołek, thank you. This helped me alot.
Very usefull to have a quick customization of the shape!
Thanks you!
not working in iOS13.
whole layout under UIViewController.view gets broken.
only works ios < 13
any ideas.
ios 13 + versions its not working "XPC Connection Interrupted"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi. I wonder if it's possible to make something like this? Thank for the QuadPageControl it helps a lot.
