Skip to content

Commit

Permalink
feat: 支持修改默认主题色
Browse files Browse the repository at this point in the history
  • Loading branch information
zackzheng committed Mar 27, 2022
1 parent f752473 commit bfaf6af
Show file tree
Hide file tree
Showing 20 changed files with 428 additions and 452 deletions.
6 changes: 3 additions & 3 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- ZPhotoPicker (3.0.18)
- ZPhotoPicker (3.0.20)

DEPENDENCIES:
- ZPhotoPicker (from `../`)
Expand All @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
ZPhotoPicker: 633c854d6a4849cb882d8176802db6eed2d46285
ZPhotoPicker: 1daaa5721dc60f92b05b436dfec8db068692f6df

PODFILE CHECKSUM: 8296adc76642b50c8369d5db18d18a804b891cec

COCOAPODS: 1.9.3
COCOAPODS: 1.11.3
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/ZPhotoPicker.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

696 changes: 343 additions & 353 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ZPhotoPicker.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'ZPhotoPicker'
s.version = '3.0.18'
s.version = '3.0.20'
s.summary = 'A short description of ZPhotoPicker.'

s.description = <<-DESC
Expand Down
6 changes: 3 additions & 3 deletions ZPhotoPicker/Assets/images.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}

This file was deleted.

Binary file not shown.
Binary file not shown.
17 changes: 14 additions & 3 deletions ZPhotoPicker/Classes/PhotoPickerImageCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,26 @@ class PhotoPickerImageCell: UICollectionViewCell {
}

if let index = index, self.isSelected {
let checkedImage: UIImage = UIImage(named: "image_checked", in: Bundle(for: ZPhotoPicker.self), compatibleWith: nil)!
checkedImage.draw(at: CGPoint(x: viewWidth - checkedImage.size.width, y: 0))
let checkedSideLength: CGFloat = 25

let rect = CGRect(origin: CGPoint(x: viewWidth - checkedSideLength, y: 0), size: CGSize(width: checkedSideLength, height: checkedSideLength))
let contextRef = UIGraphicsGetCurrentContext()!
ZPhotoPicker.themeColor.set()
contextRef.fillEllipse(in: rect)
UIColor.white.set()
contextRef.addEllipse(in: rect)
contextRef.strokePath()

let indexLabel = UILabel()
indexLabel.backgroundColor = UIColor.red
indexLabel.layer.cornerRadius = checkedSideLength / 2
indexLabel.layer.borderWidth = 1
indexLabel.layer.borderColor = UIColor.white.cgColor
indexLabel.textAlignment = .center
indexLabel.textColor = .white
indexLabel.font = .systemFont(ofSize: 13)
indexLabel.text = "\(index)"
indexLabel.drawText(in: CGRect.init(x: viewWidth - checkedImage.size.width, y: 0, width: checkedImage.size.width, height: checkedImage.size.height))
indexLabel.drawText(in: CGRect(x: viewWidth - checkedSideLength, y: 0, width: checkedSideLength, height: checkedSideLength))
}

if videoDuration > 0 {
Expand Down
2 changes: 1 addition & 1 deletion ZPhotoPicker/Classes/PhotoPickerSelectedCountView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PhotoPickerSelectedCountView: UIView {
let view = UIButton(type: .custom)
view.backgroundColor = .clear
view.setTitle("完成", for: .normal)
view.setTitleColor(UIColor(red: 1.0, green: 85.0 / 255, blue: 119.0 / 255, alpha: 1.0), for: .normal)
view.setTitleColor(ZPhotoPicker.themeColor, for: .normal)
return view
}()

Expand Down
2 changes: 2 additions & 0 deletions ZPhotoPicker/Classes/ZPhotoPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import Photos

public class ZPhotoPicker {

public static var themeColor: UIColor = UIColor.blue

public enum PhotoPickType {

case camera(allowsCropping: Bool)
Expand Down

0 comments on commit bfaf6af

Please sign in to comment.