gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 08:21:22 24 4
gpt4 key购买 nike

我有一个简单的 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com