Skip to content

Commit

Permalink
Merge pull request #120 from nohana/release/0.9.5
Browse files Browse the repository at this point in the history
0.9.5
  • Loading branch information
a2444mo10 authored Oct 22, 2021
2 parents 5f5c95e + ec17f0b commit 70d7ce7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions NohanaImagePicker/AlbumListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,29 +246,33 @@ 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: 17)
let labelItem = UIBarButtonItem(customView: label)
self.toolbarItems = [leftSpace, labelItem, rightSpace]
}

func setToolbarTitle(_ nohanaImagePickerController: NohanaImagePickerController) {
let count: Int? = toolbarItems?.count
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()
}
}

Expand Down

0 comments on commit 70d7ce7

Please sign in to comment.