UIPage控制按钮

时间:2017-06-15 22:10:17

标签: ios objective-c xcode

现在我正在使用页面控件来显示5张图像。但是,显示您所在页面的圆形指示符出现在视图的底部,而不是像我想要的那样出现在图像的正下方。我尝试使用“pageControl.frame = CGRectMake(110,5,100,100);”来更改位置。但它没有做任何事情..为什么这不起作用?

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

 }

1 个答案:

答案 0 :(得分:1)

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