Is there a way to change date from another struct using CalendarKit?

143 views Asked by At

I'm using CalendarKit and SwiftUI. I need to create "Today" button and Date Picker to select date, but I didn't foudn any solution, so is there a way to change the date or call somethign like move(to date: Date) function from another view?

1

There are 1 answers

1
Даниил Кикимов On

Here's the solution I'm using

var customDayView: DayView?


class CustomCalendarExampleController: DayViewController {
  ....
   
    override func loadView() {
        .....
        customDayView = dayView
        ...
    }
}


func moveDate(_ date: Date) {
        let offsetDate = dateOnly(date: date, calendar: customDayView!.calendar)
        customDayView!.state?.move(to: offsetDate)
    }