From 217e852bfdff77d46b4e35a448ac77370a491a8d Mon Sep 17 00:00:00 2001 From: Wojciech Lembryk Date: Thu, 24 Sep 2020 14:56:54 +0200 Subject: [PATCH] Custom cancel and done button --- Fastis.podspec | 2 +- Source/Views/Controller.swift | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Fastis.podspec b/Fastis.podspec index 4aaee4b..931ef89 100644 --- a/Fastis.podspec +++ b/Fastis.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Fastis' - s.version = '1.0.10' + s.version = '1.0.11' s.summary = "Simple date picker created using JTAppleCalendar library" s.description = <<-DESC Fastis is a fully customizable UI component for picking dates and ranges created using JTAppleCalendar library. diff --git a/Source/Views/Controller.swift b/Source/Views/Controller.swift index 69417f5..985937c 100644 --- a/Source/Views/Controller.swift +++ b/Source/Views/Controller.swift @@ -15,12 +15,24 @@ public class FastisController: UIViewController, JTACMonthVi // MARK: - Outlets private lazy var cancelBarButtonItem: UIBarButtonItem = { + if let customButton = self.appearance.customCancelButton { + customButton.target = self + customButton.action = #selector(self.cancel) + return customButton + } + let barButtonItem = UIBarButtonItem(title: self.appearance.cancelButtonTitle, style: .plain, target: self, action: #selector(self.cancel)) barButtonItem.tintColor = self.appearance.barButtonItemsColor return barButtonItem }() private lazy var doneBarButtonItem: UIBarButtonItem = { + if let customButton = self.appearance.customDoneButton { + customButton.target = self + customButton.action = #selector(self.done) + return customButton + } + let barButtonItem = UIBarButtonItem(title: self.appearance.doneButtonTitle, style: .done, target: self, action: #selector(self.done)) barButtonItem.tintColor = self.appearance.barButtonItemsColor barButtonItem.isEnabled = self.allowToChooseNilDate @@ -526,5 +538,7 @@ extension FastisConfig { public var titleTextAttributes: [NSAttributedString.Key: Any] = [:] public var backgroundColor: UIColor = .white public var barButtonItemsColor: UIColor = .systemBlue + public var customCancelButton: UIBarButtonItem? + public var customDoneButton: UIBarButtonItem? } }