ドットの色に関してUIPageViewController独自のPageControllerを変更する質問する

ドットの色に関してUIPageViewController独自のPageControllerを変更する質問する

こんにちは、私は UIPageViewController を使用して、現在のページを制御したり、スクロールしたりしています。次の 2 つの関数を追加するだけで、Page Controller を一緒に表示できることはわかっています。

- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController

- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController

私が知りたいのは、ページ コントローラーの色を変更して、使用している背景のドットをより目立たせることができるかどうかです。

通常のページ コントローラーには次のプロパティがあることがわかっています。

@property(nonatomic,retain) UIColor *currentPageIndicatorTintColor
@property(nonatomic,retain) UIColor *pageIndicatorTintColor

しかし、UIPageViewController からこれらのプロパティやページ コントローラーにアクセスする方法がどうしてもわかりません。

一般的なプロパティの変更方法を誰かが教えてくれると助かるかもしれません。

ベストアンサー1

UIAppearance を使用して UIPageControl の色を設定できます。これは、UIPageViewControllers 内の UIPageControls にも適用されます。

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

おすすめ記事