How can i change the page on clicking the dots of UIPageControl

前端 未结 4 1505
太阳男子
太阳男子 2020-12-29 18:29

Here I have a pagecontrol which works good but on clicking on dot it doesn\'t change the page so please help in the function of changepage:

- (void)viewDidLo         


        
4条回答
  •  星月不相逢
    2020-12-29 19:06

    This is very useful for pagecontrol dots click action change page index for swift 3 and swift 4 .

    @IBAction func pageControlSelectionAction(_ sender: UIPageControl) {
        let page: Int? = sender.currentPage
        var frame: CGRect = self.yourcollectionview.frame
        frame.origin.x = frame.size.width * CGFloat(page ?? 0)
        frame.origin.y = 0
        self.yourcollectionview.scrollRectToVisible(frame, animated: true)
    }
    

提交回复
热议问题