Is it possible to Increase the size of the indicator in UIPageViewController
?
I have this:
And my requirement is this:
Firstly, create an uiPageControl object inside inside viewDidLoad() and then set it's y position as per your requirement then apply required scale using CAAffiniteTransform as below:
var pageControl = UIPageControl()
pageControl.pageIndicatorTintColor = UIColor.gray
pageControl.currentPageIndicatorTintColor = UIColor.yellow
pageControl.transform = CGAffineTransform(scaleX: 1.3, y: 1.3) // set dot scale of pageControl
pageControl.backgroundColor = UIColor.darkGray
pageControl.numberOfPages = 3
pageControl.center = self.view.center
self.view.addSubview(pageControl) // add pageControl to view
pageControl.layer.position.y = self.view.frame.height - 100; // y position of the pageControl
For swift 2.0 to increase or decrease size of pageControl Indicator
self.pageControl.transform = CGAffineTransformMakeScale(0.8, 0.8)
OR
self.pageControl.transform = CGAffineTransformMakeScale(1.3, 1.3)
Scaling the page control will scale the dots, but will also scale the spacing in between them.
pageControl.transform = CGAffineTransform(scaleX: 2, y: 2)
If you want to keep the same spacing between dots, you'll need to transform the dots individually:
pageControl.subviews.forEach {
$0.transform = CGAffineTransform(scaleX: 2, y: 2)
}
However, if you do this in viewDidLoad
, the transform has been reset by the time the view appears, so you should do this in viewDidLayoutSubviews
…
override func viewDidLayoutSubviews() {
pageControl.subviews.forEach {
$0.transform = CGAffineTransform(scaleX: 2, y: 2)
}
}
You can use an UIPageControl
and scale it like this :
@IBOutlet weak var pageControl: UIPageControl!
override func viewDidLoad() {
super.viewDidLoad()
pageControl.transform = CGAffineTransform(scaleX: 2, y: 2); //set value here
}
The problem with that is that you space between your dots will be increase too. If you want to have an accurate design with your dot you have to use 3party controls : https://www.cocoacontrols.com/
Add an extension to the page controller
extension UIPageControl {
func customPageControl(dotWidth: CGFloat) {
for (pageIndex, dotView) in self.subviews.enumerated() {
dotView.frame.size = CGSize.init(width: dotWidth, height: dotWidth)
}
}
}
Swift 4, 4.2 and 5
First create an outlet of page control
@IBOutlet weak var pageControl: UIPageControl!
If you want to keep the original spacing.
override func viewDidLayoutSubviews() {
pageControl.transform = CGAffineTransform(scaleX: 2, y: 2)
}
If you don't want to keep the original spacing.
override func viewDidLayoutSubviews() {
pageControl.subviews.forEach {
$0.transform = CGAffineTransform(scaleX: 2, y: 2)
}
}