I31
I31

Reputation: 67

UIPage Control Buttons

Right now I'm using page control to display 5 images. However the circle indicators showing which page you are on are appearing at the bottom of the view instead of right underneath the image like I want. I attempted to change the location using "pageControl.frame = CGRectMake(110,5,100,100);" but it does nothing.. Any reason why this is not working?

- (void)viewDidLoad {
   [super viewDidLoad];
  // Do any additional setup after loading the view, typically from a 
  nib.

  _pageData = @[@"slide0.png", @"slide1.png", @"slide2.png", 
 @"slide3.png", @"slide4.png", @"slide5.png"];

_pageViewController = [[UIPageViewController alloc]

 initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll

   navigationOrientation: 
   UIPageViewControllerNavigationOrientationHorizontal
                       options:nil];

_pageViewController.delegate = self;
_pageViewController.dataSource = self;

DataViewController *startingViewController = [self viewControllerAtIndex:0 storyboard:self.storyboard];
NSArray *viewControllers = @[startingViewController];

[_pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

[self addChildViewController:_pageViewController];
[self.view addSubview:_pageViewController.view];

// Set the page view controller's bounds using an inset rect so that self's view is visible around the edges of the pages.
CGRect pageViewRect = self.view.bounds;
_pageViewController.view.frame = pageViewRect;

[_pageViewController didMoveToParentViewController:self];

UIPageControl *pageControl = [UIPageControl appearance];

pageControl.frame = CGRectMake(110,5,100,100);

pageControl.pageIndicatorTintColor = [UIColor lightGrayColor];
pageControl.currentPageIndicatorTintColor = [UIColor blackColor];
pageControl.backgroundColor = [UIColor whiteColor];    

 }

Upvotes: 0

Views: 36

Answers (1)

vaibby
vaibby

Reputation: 1265

- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray<UIViewController *> *)previousViewControllers transitionCompleted:(BOOL)completed {
pageControl.currentPage = pageViewController.currentPageNumber;
}

Upvotes: 1

Related Questions