Skip to content

Commit

Permalink
- added "calendarIconImage"
Browse files Browse the repository at this point in the history
  • Loading branch information
rursache committed Mar 12, 2024
1 parent 0f5853a commit e2db5cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Files/RSDatePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
// RSDatePicker
//
// Created by Radu Ursache - RanduSoft
// v1.5.0
// v1.7.1
//

/*

Known issues:
Known issues:
- Selecting the same day in different month/year with closeWhenSelectingDate = true will not close the popup. Fixing this will actually make the popup close for each month/year change
- The popup will be presented over the view when using a big frame height. This could be fixed by fiddling with the transform of the underlaying date picker

*/

import UIKit
Expand Down Expand Up @@ -91,6 +89,11 @@ open class RSDatePicker: UIView {
self.layoutIfNeeded()
}
}
public var calendarIconImage: UIImage = UIImage(systemName: "calendar")! {
didSet {
self.calendarImageView.image = self.calendarIconImage
}
}
public var font: UIFont? {
didSet {
self.dateLabel.font = self.font
Expand Down Expand Up @@ -171,7 +174,7 @@ open class RSDatePicker: UIView {
self.updateUI()
}

open func updateUI() {}
open func updateUI() { }

private func prepareDatePicker() {
self.hideDateLabel()
Expand Down Expand Up @@ -360,8 +363,8 @@ fileprivate extension UIView {
}
}

class func getAllSubviews(from parenView: UIView, types: [UIView.Type]) -> [UIView] {
return parenView.subviews.flatMap { subView -> [UIView] in
class func getAllSubviews(from parentView: UIView, types: [UIView.Type]) -> [UIView] {
return parentView.subviews.flatMap { subView -> [UIView] in
var result = getAllSubviews(from: subView) as [UIView]
for type in types {
if subView.classForCoder == type {
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ You can customize the date picker in multiple ways:
- `closeAnimationDuration` controls the animation speed when closing the picker
- `calendarIconIsHidden` controls if the calendar icon is hidden
- `calendarIconSizeMultiplier` controls the multiplier of the aspect ratio of the calendar imageview
- `calendarIconImage` sets the calendar icon
- `left/right/top/bottomMargin` changes the margins of the container view

There is also a callback for receiving the new picked date: `didChangeDate`
Expand Down Expand Up @@ -52,6 +53,7 @@ self.datePicker.initialText = "Select Date"
self.datePicker.calendarIconIsHidden = false
self.datePicker.calendarIconTint = .label
self.datePicker.calendarIconSizeMultiplier = 0.8
self.datePicker.calendarIconImage = UIImage(systemName: "calendar")!
self.datePicker.forceScalePicker = true
self.datePicker.closeWhenSelectingDate = true
self.datePicker.minimumDate = Calendar.current.date(byAdding: .day, value: -4, to: Date()) // 4 days ago
Expand Down

0 comments on commit e2db5cc

Please sign in to comment.