Skip to content

How to change the colour of day selection ?Β #375

@emircodes

Description

@emircodes
Image

Hello, I am currently trying to change the colour of the day selection to Purple, the image I have attached is what I am trying to achieve (By default the day selection is Red). However, I am not exactly sure how to implement this. I have tried using calendar style but I am quite unsure if it is the method to change the colour of the day selection to Purple.

Below is my current code:


class CustomDayViewController: DayViewController {
    override func loadView() {
        
        // Note: changing M T W T F S S -> S M T W T F S
        
        let sundayFirstCalendar: Calendar = {
            var calendar = Calendar(identifier: .gregorian)
            calendar.locale = Locale(identifier: "en_US_POSIX")
            calendar.firstWeekday = 1
            return calendar
        }()

        dayView = DayView(calendar: sundayFirstCalendar)
        view = dayView
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        dayView.autoScrollToFirstEvent = true
        dayView.backgroundColor = .systemBackground
        
        //dayView.dayHeaderView.daySelectorView.tintColor = .systemPurple
    }

    override func eventsForDate(_ date: Date) -> [EventDescriptor] {
        return []
    }
}


struct CalendarKitView: UIViewControllerRepresentable {
    func makeUIViewController(context: Context) -> CustomDayViewController {
        return CustomDayViewController()
    }

    func updateUIViewController(_ uiViewController: CustomDayViewController, context: Context) {
        
    }
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions