From e2db5cce71902e101acdee82a62653ea8101ea07 Mon Sep 17 00:00:00 2001 From: Radu Ursache <radu@ursache.ro> Date: Tue, 12 Mar 2024 15:36:42 +0200 Subject: [PATCH] - added "calendarIconImage" --- Files/RSDatePicker.swift | 17 ++++++++++------- README.md | 2 ++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Files/RSDatePicker.swift b/Files/RSDatePicker.swift index 41d5c83..1d0be20 100644 --- a/Files/RSDatePicker.swift +++ b/Files/RSDatePicker.swift @@ -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 @@ -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 @@ -171,7 +174,7 @@ open class RSDatePicker: UIView { self.updateUI() } - open func updateUI() {} + open func updateUI() { } private func prepareDatePicker() { self.hideDateLabel() @@ -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 { diff --git a/README.md b/README.md index d4e9219..3a5f114 100644 --- a/README.md +++ b/README.md @@ -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` @@ -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