Access the UIPageControl created by iOS6 UIPageViewController?

后端 未结 8 1041
盖世英雄少女心
盖世英雄少女心 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 03:12

    How about a nice, up to date Swift 1-liner?

    let pageControl = view.subviews.first { $0 is UIPageControl } as? UIPageControl
    

    Or if you like an extension:

    extension UIPageViewController {
        var pageControl: UIPageControl? {
            return view.subviews.first { $0 is UIPageControl } as? UIPageControl
        }
    }
    

提交回复
热议问题