How to set color for background view in UIPageViewController
? Is it possible to do this in Storyboard?

- 69,473
- 35
- 181
- 253

- 59,234
- 49
- 233
- 358
5 Answers
edit: I thought the question was about UIPageControl.
You should be able to simply modify the color of the UIPageViewController's view:
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor blueColor]; //Set to any color.
}

- 416
- 5
- 9
In this case, you need to change UIPageControl of UIPageViewCotroller.
Try this.
UIPageControl* proxy = [UIPageControl appearanceWhenContainedIn:[self.pageViewController class], nil];
[proxy setPageIndicatorTintColor:[UIColor lightGrayColor]];
[proxy setCurrentPageIndicatorTintColor:[UIColor blackColor]];
[proxy setBackgroundColor:[UIColor whiteColor]];
If you project is written by swift, try this.
let proxy: UIPageControl = UIPageControl.appearanceWhenContainedInInstancesOfClasses(self.pageViewController.self)
proxy.pageIndicatorTintColor = UIColor.lightGrayColor()
proxy.currentPageIndicatorTintColor = UIColor.blackColor()
proxy.backgroundColor = UIColor.whiteColor()

- 762
- 6
- 15
-
Question is about scrollView color of UIPageViewController, not about UIPageControl. – kelin Nov 17 '15 at 10:54
-
The question is, " How to set the background color of a UIPageViewController " and not about UIPageControl, please edit your answer. – Sep 24 '17 at 06:32
Inside UIPageViewController's view, you can use this code:
override func viewDidLoad() {
super.viewDidLoad()
// Set backbround color to white
self.view.backgroundColor = UIColor.white
}
I've set the color to white, but you can pretty much insert whatever color you want.
Cheers!

- 859
- 1
- 8
- 16
Yes you can change the background color, but it doesn't appear to be exposed in Interface Builder.
Following the proscribed method for setting up the page view controller in IB, you need to:
1. Add a UIContainerView to your view controller
2. Add a UIPageViewController to the storyboard
3. Add a Embed segue from the UIViewContainer to the UIPageViewController (with the identifier myPageViewController)
The from your original view controller, add this to your prepareForSegue
method:
if ([segueName isEqualToString: @"myPageViewController"]) {
/* _pageViewController is a property where I keep a reference to the embedded controller */
if (_pageViewController == nil) {
/* only do this once */
_pageViewController = (WePageViewController*)[segue destinationViewController];
_pageViewController.dataSource = ...;
_pageViewController.delegate = ...;
_pageViewController.view.backgroundColor = [UIColor purpleColor];
}
p.s. apologies as I haven't moved to Swift yet...

- 4,647
- 3
- 25
- 40
To change the background colour , use the UIPageControl
and assign the backgroundColor
property to the desired UIColor
UIPageControl *pageControl = [UIPageControl appearance];
pageControl.backgroundColor = [UIColor orangeColor];

- 13
- 1
- 2