I'm a new programer and I am trying to use FSCalendar to create a calendar like iOS Fitness App.
Like this:
but I don't know how to.
Now I try to .scope = .week
.
In cell I use self.titleLabel.isHidden = true
to hide date.
import UIKit
import FSCalendar
import MKRingProgressView
class ViewController: UIViewController, FSCalendarDataSource, FSCalendarDelegate {
fileprivate weak var calendar: FSCalendar!
override func viewDidLoad() {
super.viewDidLoad()
let screenWidth = self.view.bounds.width
let calendarView = FSCalendar(frame: CGRect(x: 0, y: 60, width: screenWidth, height: 300))
calendarView.dataSource = self
calendarView.delegate = self
view.addSubview(calendarView)
calendarView.register(CustomCalendarCell.self, forCellReuseIdentifier: "CustomCalendarCell")
calendarView.locale = .init(identifier: "zh-tw")
calendarView.appearance.caseOptions = .weekdayUsesSingleUpperCase
calendarView.scope = .week
calendarView.firstWeekday = 2
calendarView.weekdayHeight = 40
calendarView.appearance.headerTitleFont = UIFont.systemFont(ofSize: 0) // Hide the title
calendarView.headerHeight = 0
}
func calendar(_ calendar: FSCalendar, cellFor date: Date, at monthPosition: FSCalendarMonthPosition) -> FSCalendarCell {
// Return custom cells for visible dates
let cell = calendar.dequeueReusableCell(withIdentifier: "CustomCalendarCell", for: date, at: monthPosition) as! CustomCalendarCell
configureCustomView(cell.customView, for: date)
return cell
}
func configureCustomView(_ customView: RingProgressView, for date: Date) {
if date > Date() {
customView.layer.opacity = 0.2
} else {
customView.layer.opacity = 1
}
}
}
But I don't know how to select weekdayLabels and make today's weekdayLabel color change to make it like Fitness App.