【问题标题】:iOS - Change PageControl indicator of UIPageViewControlleriOS - 更改 UIPageViewController 的 PageControl 指示器
【发布时间】:2014-12-11 08:58:30
【问题描述】:

我想将点指示器更改为分段控件。是否可以?如何?我知道我可以像这样自定义点:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    ...
    UIPageControl *pageControl = [UIPageControl appearance];
    pageControl.pageIndicatorTintColor = [UIColor lightGrayColor];
    pageControl.currentPageIndicatorTintColor = [UIColor blackColor];
    pageControl.backgroundColor = [UIColor blueColor];
    ...
}

但我希望它改变为全新的控制。如果不可能,那么使用 UIPageViewControllerTransitionStyleScroll 创建相同的 UIPageController 但使用分段控件的最佳方法是什么?谢谢

【问题讨论】:

  • 尝试自定义 UIPageControl。
  • 您的意思是创建继承自 UIPageControl 的自定义类对吧?没问题,但是如何将其设置为默认 UIPageControl?

标签: ios ios7 uisegmentedcontrol uipageviewcontroller uipagecontrol


【解决方案1】:

这里有一个很好的解决方案:

Is there a way to change page indicator dots color

而不是创建 UIPageControl 对象创建 GreyPageControl 对象。其他的都是这样。

希望这会有所帮助。

【讨论】:

  • 如何创建自定义 UIPageControl 很清楚,谢谢。但我不知道如何将它与 UIPageViewController 一起使用。我不创建 UIPageControl。它是通过使用 self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil]; 创建的,我可以在 AppDelegate 中修改它,但只能使用我在问题中显示的代码进行颜色。
  • 在您给出的代码中,您使用的是 UIPageControl,所以与其使用它,不如使用 GreyPageControl
  • 这是可以改变 UIPageControl 颜色的代码,但我只是得到它,我没有将它分配给 UIPageViewController。如果我尝试GrayPageControl *pageControl = [UIPageControl appearance]; 它不会改变任何东西。
  • GrayPageControl *pageControl = [GrayPageControl 外观];
  • 它没有帮助。代码示例如本教程中的:appcoda.com/uipageviewcontroller-storyboard-tutorial 在自定义页面指示器部分。
猜你喜欢
  • 1970-01-01
  • 2015-06-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-11
相关资源
最近更新 更多