UIPageViewController black background when sliding more

折月煮酒 提交于 2020-01-03 13:04:21

问题


I'm using UIPageViewController to create some introduction slides for my objective-c app.

But when I slide more in the first slide to left or slide last slider image more to right, I can see a black background.

How can I prevent user sliding more left in first slider & sliding more right in the last slider.

Thanks a lot.


回答1:


A quick and easy solution can be to place a UIView behind your UIpageView. This way, you won't be getting black background.

Also have a look at this stack overflow's question. It explains in detail how to Disable UIPageViewController




回答2:


Swift 3 code inspired by @Munahil:

class TutorialViewController : UIPageViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        ...

        // Add view to mask default black background of UIPageViewControllers
        let bgView = UIView(frame: UIScreen.main.bounds)
        bgView.backgroundColor = UIColor.blue
        view.insertSubview(bgView, at: 0)

        ...
    }


来源:https://stackoverflow.com/questions/31932977/uipageviewcontroller-black-background-when-sliding-more

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!