Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add circle to selected dates #563

Closed
ghost opened this issue Mar 7, 2019 · 1 comment
Closed

Add circle to selected dates #563

ghost opened this issue Mar 7, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented Mar 7, 2019

So I have an array of dates. I want to add circle in the calendar, to the dates that is in the array. How can I do that? I know about this function below. But how can I add rings to all the dates in CalendarView that are equal to the dates in my array?:

func supplementaryView(shouldDisplayOnDayView dayView: DayView) -> Bool {
        guard let currentCalendar = currentCalendar else { return false }
        
        var components = Manager.componentsForDate(Foundation.Date(), calendar: currentCalendar)
        
        /* For consistency, always show supplementaryView on the 3rd, 13th and 23rd of the current month/year.  This is to check that these expected calendar days are "circled". There was a bug that was circling the wrong dates. A fix was put in for #408 #411.
         
         Other month and years show random days being circled as was done previously in the Demo code.
         */
        var shouldDisplay = false
        if dayView.date.year == components.year &&
            dayView.date.month == components.month {
            
            if (dayView.date.day == 3 || dayView.date.day == 13 || dayView.date.day == 23)  {
                print("Circle should appear on " + dayView.date.commonDescription)
                shouldDisplay = true
            }
        } else if (Int(arc4random_uniform(3)) == 1) {
            shouldDisplay = true
        }
        
        return shouldDisplay
    }
@ghost
Copy link
Author

ghost commented Mar 8, 2019

Fixed it by myself:

    func supplementaryView(shouldDisplayOnDayView dayView: DayView) -> Bool {
        guard let currentCalendar = currentCalendar else { return false }
        
        let day = dayView.date.convertedDate()
        
        var shouldDisplay = false
        let val = result.filter { compareDate(date1:$0.date!, date2:day!) }
        if val.isEmpty == false {
            shouldDisplay = true
        }
        
        return shouldDisplay
    }

@ghost ghost closed this as completed Mar 8, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants