UIPageViewController page control background color

后端 未结 9 1347
一个人的身影
一个人的身影 2020-12-13 00:23

i\'m using UIPageViewController in my app and it\'s working fine. however, it\'s page control which has been added automatically has a black background which is hiding the c

9条回答
  •  佛祖请我去吃肉
    2020-12-13 00:32

    Updated for Swift 3:

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        for view in self.view.subviews {
            if view is UIScrollView {
                view.frame = UIScreen.main.bounds
            } else if view is UIPageControl {
                view.backgroundColor = UIColor.clear
            }
        }
    }
    

    Swift 2 example for anyone that needs it. Put this inside your UIPageController subclass.

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        for view in self.view.subviews {
            if view is UIScrollView {
                view.frame = UIScreen.mainScreen().bounds
            } else if view is UIPageControl {
                view.backgroundColor = UIColor.clearColor()
            }
        }
    }
    

提交回复
热议问题