ios - 如何在 iOS >=8.0 中更改 UIPageControl 的位置?

标签 ios uipageviewcontroller uipagecontrol

我有一个简单的 UIPageViewController,它在页面底部显示默认的 UIPageControl。我想知道是否可以修改 UIPageControl 的位置,例如位于屏幕顶部而不是底部。 我环顾四周,只发现旧的讨论说我需要创建自己的 UIPageControl。 这件事在 iOS8 和 9 上更简单吗? 谢谢。

最佳答案

是的,您可以为此添加自定义页面 Controller 。

self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 50, self.view.frame.size.width, 50)]; // your position

[self.view addSubview: self.pageControl];

然后删除

- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController

- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController

然后添加另一个委托(delegate)方法:

- (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray<UIViewController *> *)pendingViewControllers
 {
     PageContentViewController *pageContentView = (PageContentViewController*) pendingViewControllers[0];
     self.pageControl.currentPage = pageContentView.pageIndex;
 }

关于ios - 如何在 iOS >=8.0 中更改 UIPageControl 的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32822724/

相关文章:

iphone - 如何在推送 UIViewController 之前预加载 UITableView?

ios - 默认情况下不显示 UIPageViewController 中的 InputAccessoryView

iphone - iOS/Obj-C UIScrollView 和 PageControl 不工作

ios - swift 警告 : A lonng-running operation is being executed on the main thread

ios - 如何将 StatusBar 样式更新为自定义转换的一部分

ios - 在 UITableViewCell 中模糊图像时出现性能问题

ios - UIPageViewController - 如果没有页面则不允许移动

iOS - 在 Notes 应用程序上模拟键盘动画

ios - UIPageViewController 翻页示例

ios - 如何将 UIPageControl 连接到 UICollectionView (Swift)