| | |
| | | @IBOutlet weak var view_container: UIView! |
| | | @IBOutlet weak var view_topContainer: UIView! |
| | | @IBOutlet weak var cons_hei: NSLayoutConstraint! |
| | | private var clouse:((Date)->Void)? |
| | | |
| | | lazy private var calendar:FSCalendar = { |
| | | let calendar = FSCalendar() |
| | |
| | | } |
| | | |
| | | |
| | | static func show(){ |
| | | static func show(selectDate:Date? = nil,clouse:@escaping (Date)->Void){ |
| | | let calendarPickerView = CalendarPickerView.jq_loadNibView() |
| | | calendarPickerView.frame = screnDelegate?.window?.frame ?? .zero |
| | | calendarPickerView.clouse = clouse |
| | | screnDelegate?.window?.addSubview(calendarPickerView) |
| | | calendarPickerView.cons_hei.constant = 495 |
| | | calendarPickerView.calendar.frame = CGRect(x: 0, y: 0, width: JQ_ScreenW, height: 370) |
| | | UIView.animate(withDuration: 0.4) { |
| | | calendarPickerView.alpha = 1 |
| | | calendarPickerView.layoutIfNeeded() |
| | | }completion: { _ in |
| | | if selectDate != nil{ |
| | | calendarPickerView.calendar.setCurrentPage(selectDate!, animated: false) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | extension CalendarPickerView:FSCalendarDelegate{ |
| | | func calendar(_ calendar: FSCalendar, didSelect date: Date, at monthPosition: FSCalendarMonthPosition) { |
| | | clouse?(date) |
| | | cons_hei.constant = 0 |
| | | UIView.animate(withDuration: 0.4) { |
| | | self.alpha = 0 |
| | | self.view_topContainer.layoutIfNeeded() |
| | | } completion: { _ in |
| | | self.removeFromSuperview() |
| | | } |
| | | |
| | | } |
| | | } |