简体   繁体   中英

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];    

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM