Skip to content

Instantly share code, notes, and snippets.

@olxios
Created June 5, 2016 11:18
Show Gist options
  • Save olxios/324aa9b88ed4435dcd4c1bdfa4aa337f to your computer and use it in GitHub Desktop.
Save olxios/324aa9b88ed4435dcd4c1bdfa4aa337f to your computer and use it in GitHub Desktop.
@implementation ViewController
#pragma mark View Lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
[self createPageViewController];
[self setupPageControl];
}
- (void)createPageViewController
{
_contentImages = @[@"nature_pic_1",
@"nature_pic_2",
@"nature_pic_3",
@"nature_pic_4"];
UIPageViewController *pageController = [self.storyboard instantiateViewControllerWithIdentifier:@"PageController"];
pageController.dataSource = self;
if([_contentImages count])
{
NSArray *startingViewControllers = @[[self itemControllerForIndex:0]];
[pageController setViewControllers:startingViewControllers
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];
}
self.pageViewController = pageController;
[self addChildViewController:self.pageViewController];
[self.view addSubview:self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
}
- (void)setupPageControl
{
[[UIPageControl appearance] setPageIndicatorTintColor:[UIColor grayColor]];
[[UIPageControl appearance] setCurrentPageIndicatorTintColor:[UIColor whiteColor]];
[[UIPageControl appearance] setBackgroundColor:[UIColor darkGrayColor]];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment