From 8a59bbfd42c2f1f70d0b18193de30942ab535d41 Mon Sep 17 00:00:00 2001 From: "atsushi.yoshimoto" Date: Wed, 13 Oct 2021 16:55:26 +0900 Subject: [PATCH 1/2] Modified to use customview of UIBarButtonItem. --- .../AlbumListViewController.swift | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/NohanaImagePicker/AlbumListViewController.swift b/NohanaImagePicker/AlbumListViewController.swift index 2c7a4eb..87fb119 100644 --- a/NohanaImagePicker/AlbumListViewController.swift +++ b/NohanaImagePicker/AlbumListViewController.swift @@ -246,10 +246,12 @@ extension UIViewController { let leftSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) let rightSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) - let infoButton = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) - infoButton.isEnabled = false - infoButton.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.systemFont(ofSize: 14), NSAttributedString.Key.foregroundColor: UIColor.black], for: UIControl.State()) - self.toolbarItems = [leftSpace, infoButton, rightSpace] + let label = UILabel() + label.textColor = .black + label.textAlignment = .center + label.font = .systemFont(ofSize: 16) + let labelItem = UIBarButtonItem(customView: label) + self.toolbarItems = [leftSpace, labelItem, rightSpace] } func setToolbarTitle(_ nohanaImagePickerController: NohanaImagePickerController) { @@ -257,18 +259,20 @@ extension UIViewController { guard count != nil && count! >= 2 else { return } - guard let infoButton = toolbarItems?[1] else { + guard let labelItem = toolbarItems?[1], let titleLabel = labelItem.customView as? UILabel else { return } if nohanaImagePickerController.maximumNumberOfSelection == 0 { let title = String(format: nohanaImagePickerController.config.strings.toolbarTitleNoLimit ?? NSLocalizedString("toolbar.title.nolimit", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: ""), nohanaImagePickerController.pickedAssetList.count) - infoButton.title = title + titleLabel.text = title + titleLabel.sizeToFit() } else { let title = String(format: nohanaImagePickerController.config.strings.toolbarTitleHasLimit ?? NSLocalizedString("toolbar.title.haslimit", tableName: "NohanaImagePicker", bundle: nohanaImagePickerController.assetBundle, comment: ""), nohanaImagePickerController.pickedAssetList.count, nohanaImagePickerController.maximumNumberOfSelection) - infoButton.title = title + titleLabel.text = title + titleLabel.sizeToFit() } } From 711fe08bc254aa8c1d77f330e45216ec2a38c651 Mon Sep 17 00:00:00 2001 From: "atsushi.yoshimoto" Date: Fri, 15 Oct 2021 18:30:01 +0900 Subject: [PATCH 2/2] Modified font size. --- NohanaImagePicker/AlbumListViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NohanaImagePicker/AlbumListViewController.swift b/NohanaImagePicker/AlbumListViewController.swift index 87fb119..5b2ac42 100644 --- a/NohanaImagePicker/AlbumListViewController.swift +++ b/NohanaImagePicker/AlbumListViewController.swift @@ -249,7 +249,7 @@ extension UIViewController { let label = UILabel() label.textColor = .black label.textAlignment = .center - label.font = .systemFont(ofSize: 16) + label.font = .systemFont(ofSize: 17) let labelItem = UIBarButtonItem(customView: label) self.toolbarItems = [leftSpace, labelItem, rightSpace] }