5

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.

enter image description here

enter image description here

Pradeep Singh
  • 752
  • 1
  • 10
  • 23
Udaya Sri
  • 2,372
  • 2
  • 25
  • 35

2 Answers2

3

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)

        ...
    }
Crashalot
  • 33,605
  • 61
  • 269
  • 439
2

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

Community
  • 1
  • 1
Munahil
  • 2,381
  • 1
  • 14
  • 24