Search code examples
swiftuipagecontrol

Swift PageControl larger dot on current page


I am attempting to scale dot of the current page to be larger than the dots which are not 'selected'.

I am using the scrollview delegate to ascertain which page is current.

At the moment there is no change to the size of the dot.

How would I go about achieving this?

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {

    var i = 0
    if(scrollView.contentOffset.x < scrollView.frame.width){

      pageControl.currentPage = 0
        pageControl.subviews.forEach {

            if(i == 0){
                print("Edit")
                $0.transform.scaledBy(x: 5, y: 5)
            }

            pageControl.layoutIfNeeded()
            i += 1
        }


    }else{
         pageControl.currentPage = 1
    }
}

Solution

  • UIPageControl is not that customizable. Use a library like this one

    TAPageControl

    Is works the same way as UIPageControl and you can easily customize current and non current page dots by setting the properties dotImage and currentDotImage.