Skip to content

Commit b1b0504

Browse files
author
YanAn
committed
replace checkmarkImage and render mode
support change theme color
1 parent 3ab3269 commit b1b0504

File tree

7 files changed

+14
-11
lines changed

7 files changed

+14
-11
lines changed
-2.36 KB
Binary file not shown.

PhotoPicker/AssetCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class AssetCell: UICollectionViewCell {
4343
}
4444

4545
func setChecked(_ checked: Bool, animation: Bool) {
46-
checkMarkImageView.image = checked ? UIImage(named: selectedCheckMarkImageName, in: currentBundle, compatibleWith: nil) : UIImage(named: unselectedCheckMarkImageName, in: currentBundle, compatibleWith: nil)
46+
checkMarkImageView.image = checked ? UIImage(named: selectedCheckMarkImageName, in: currentBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) : UIImage(named: unselectedCheckMarkImageName, in: currentBundle, compatibleWith: nil)
4747
if !self.checked && checked && animation {
4848
UIView.animateKeyframes(withDuration: 0.33, delay: 0.0, options: [], animations: { () -> Void in
4949
UIView.addKeyframe(withRelativeStartTime: 0.0, relativeDuration: 0.5, animations: { [unowned self]() -> Void in

PhotoPicker/AssetsViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ extension AssetsViewController {
224224
let numberBarItem = UIBarButtonItem(customView: toolbarNumberView)
225225
let leftSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
226226
toolbarItems = [highqualityBarItem, leftSpace, numberBarItem, sendBarItem]
227-
228-
navigationController?.toolbar.tintColor = toolBarTintColor
227+
navigationController?.toolbar.tintColor = themeToolBarTintColor
229228
navigationController?.setToolbarHidden(false, animated: true)
230229
}
231230

PhotoPicker/PhotoPickerController.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@ open class PhotoPickerController: UIViewController {
2424
//MARK: - private property
2525
fileprivate var albumsNavigationController: UINavigationController!
2626

27-
public init(localizedStrings: [String: String]) {
27+
public init(localizedStrings: [String: String], themeColor: UIColor? = nil) {
2828
super.init(nibName:nil, bundle:nil)
2929

3030
self.assetCollectionSubtypes = [.smartAlbumUserLibrary,
3131
.smartAlbumFavorites,
3232
.albumMyPhotoStream,
3333
.albumCloudShared,
3434
.albumRegular]
35-
35+
36+
if let color = themeColor {
37+
themeToolBarTintColor = color
38+
themeTextColor = color
39+
}
3640
setupAlbumsViewController()
3741
localizedString = localizedStrings
3842

@@ -54,7 +58,6 @@ open class PhotoPickerController: UIViewController {
5458

5559
open override func viewDidLoad() {
5660
super.viewDidLoad()
57-
5861
// Do any additional setup after loading the view.
5962
}
6063

PhotoPicker/ToolBarHighQualityButton.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ class ToolBarHighQualityButton: UIView {
1515
weak var assetsViewController: AssetsViewController!
1616

1717
//MARK: - public property
18+
var themeColor: UIColor?
1819
var checked: Bool = false {
1920
didSet {
2021
if checked {
21-
imageView.image = UIImage(named: toolbarHighQualityImageCheckedImageName, in: currentBundle, compatibleWith: nil)
22-
titleLabel.textColor = blueTextColor
22+
imageView.image = UIImage(named: toolbarHighQualityImageCheckedImageName, in: currentBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
23+
titleLabel.textColor = themeTextColor
2324
assetsViewController.updateHighQualityImageSize()
2425
} else {
2526
imageView.image = UIImage(named: toolbarHighQualityImageUnCheckedImageName, in: currentBundle, compatibleWith: nil)

PhotoPicker/ToolBarNumberView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ToolBarNumberView: UIView {
3636

3737
func setupProperty() {
3838
imageView = UIImageView(frame: bounds)
39-
imageView.image = UIImage(named: toolbarNumberViewBackgroundImageName, in: currentBundle, compatibleWith: nil)
39+
imageView.image = UIImage(named: toolbarNumberViewBackgroundImageName, in: currentBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
4040
imageView.isHidden = true
4141

4242
numberLabel = UILabel(frame: bounds)

PhotoPicker/constant.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import UIKit
1010

11-
let toolBarTintColor: UIColor = UIColor(red: 3/255.0, green: 169/255.0, blue: 244/255.0, alpha: 1.0)
11+
var themeToolBarTintColor: UIColor = UIColor(red: 3/255.0, green: 169/255.0, blue: 244/255.0, alpha: 1.0)
1212
let greyTextColor: UIColor = UIColor(red: 191/255.0, green: 191/255.0, blue: 191/255.0, alpha: 1.0)
13-
let blueTextColor: UIColor = UIColor(red: 3/255.0, green: 169/255.0, blue: 244/255.0, alpha: 1.0)
13+
var themeTextColor: UIColor = UIColor(red: 3/255.0, green: 169/255.0, blue: 244/255.0, alpha: 1.0)
1414
let AlbumCoverBorderColor: CGColor = UIColor.white.cgColor
1515
let currentBundle: Bundle = Bundle(for: PhotoPickerController.self)
1616
let selectedCheckMarkImageName = "checkmark_selected"

0 commit comments

Comments
 (0)