From 77602fcb86a09905f9decaa90ca6d36eb22d1288 Mon Sep 17 00:00:00 2001 From: "naoto.suzuki" Date: Thu, 17 Mar 2022 16:45:08 +0900 Subject: [PATCH] Added config color. --- .../AssetListSelectableDateSectionController.swift | 10 ++++++++++ NohanaImagePicker/NohanaImagePickerController.swift | 1 + NohanaImagePicker/RootViewController.swift | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/NohanaImagePicker/AssetListSelectableDateSectionController.swift b/NohanaImagePicker/AssetListSelectableDateSectionController.swift index ebacd64..269fd99 100644 --- a/NohanaImagePicker/AssetListSelectableDateSectionController.swift +++ b/NohanaImagePicker/AssetListSelectableDateSectionController.swift @@ -60,6 +60,7 @@ class AssetListSelectableDateSectionController: UICollectionViewController, UICo override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) setToolbarTitle(nohanaImagePickerController) + updateDoneBarButtonColor() collectionView?.reloadData() } @@ -73,6 +74,13 @@ class AssetListSelectableDateSectionController: UICollectionViewController, UICo } } + private func updateDoneBarButtonColor() { + parent?.navigationItem.rightBarButtonItem?.setTitleTextAttributes([ + .foregroundColor: nohanaImagePickerController.config.color.navigationBarDoneBarButtonItem, + .font: UIFont.systemFont(ofSize: 17, weight: .semibold) + ], for: .normal) + } + // MARK: - UICollectionViewDataSource override func numberOfSections(in collectionView: UICollectionView) -> Int { @@ -242,6 +250,7 @@ class AssetListSelectableDateSectionController: UICollectionViewController, UICo extension AssetListSelectableDateSectionController: AssetDateSectionHeaderViewDelegate { func didPushPickButton() { collectionView.reloadItems(at: collectionView.indexPathsForVisibleItems) + updateDoneBarButtonColor() } } @@ -263,5 +272,6 @@ extension AssetListSelectableDateSectionController: AssetCellDelegate { } } } + updateDoneBarButtonColor() } } diff --git a/NohanaImagePicker/NohanaImagePickerController.swift b/NohanaImagePicker/NohanaImagePickerController.swift index fb0ce42..4c98908 100644 --- a/NohanaImagePicker/NohanaImagePickerController.swift +++ b/NohanaImagePicker/NohanaImagePickerController.swift @@ -172,6 +172,7 @@ extension NohanaImagePickerController { public var separator: UIColor? public var navigationBarBackground: UIColor = .white public var navigationBarForeground: UIColor = .black + public var navigationBarDoneBarButtonItem: UIColor = .black } public var color = Color() diff --git a/NohanaImagePicker/RootViewController.swift b/NohanaImagePicker/RootViewController.swift index bd5a529..790c6a0 100644 --- a/NohanaImagePicker/RootViewController.swift +++ b/NohanaImagePicker/RootViewController.swift @@ -88,7 +88,7 @@ class RootViewController: UIViewController { // FIXME: The settings of UIBarButtonItemAppearance may not be reflected. // Probably, this problem occurs when the settings are set to reflect the entire application. navigationItem.rightBarButtonItem?.setTitleTextAttributes([ - .foregroundColor: nohanaImagePickerController.config.color.navigationBarForeground, + .foregroundColor: nohanaImagePickerController.config.color.navigationBarDoneBarButtonItem, .font: UIFont.systemFont(ofSize: 17, weight: .semibold) ], for: .normal) }