macOS, iOS

[SwiftUI] Custom calendar 만들기 - FSCalendar

SweetDev 2021. 3. 1. 17:45

 

이런 캘린더가 필요했는데... 많은 고민 끝에 FSCalendar을 SwiftUI로 바꿔서 쓰기로 결정했다. 

 

struct CalendarView: UIViewRepresentable {
  typealias UIViewType = FSCalendar
  func makeUIView(context: Context) -> FSCalendar {
    let calendar = FSCalendar()
    calendar.delegate = context.coordinator
    calendar.dataSource = context.coordinator
    return calendar
  }

  func updateUIView(_ uiView: FSCalendar, context: Context) {}
  class Coordinator: NSObject, FSCalendarDelegate, FSCalendarDataSource {}

  func makeCoordinator() -> Coordinator {
    return Coordinator()
  }
}