Access the UIPageControl created by iOS6 UIPageViewController?

后端 未结 8 1161
盖世英雄少女心
盖世英雄少女心 2021-01-05 02:42

I\'m using a UIPageViewController with Navigation set to Horizontal, Transition Style set to Scroll (in InterfaceBuilder), and no spine. Which gives me a lovely

8条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-05 02:47

    For Swift

    To get the dots in the page control we can use

    //dots will be an array of the dots views
    let dots = pageControl.subviews
    

    To get the current dot view

    let currentDot = dots[pageControl.currentPage]
    

    To get the other dots views

    for i in 0.. current dot
    
    
    
        } else {
            //dot => other dot
    
        }
    }
    

    After we get the dot view we can change whatever we want like

    dot.layer.borderColor = .green
    dot.layer.borderWidth = 1
    

提交回复
热议问题