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

Modifying DateButton to create an event #49

Open
jaime-fuhr opened this issue Oct 5, 2013 · 2 comments
Open

Modifying DateButton to create an event #49

jaime-fuhr opened this issue Oct 5, 2013 · 2 comments

Comments

@jaime-fuhr
Copy link

I added the following code to CKCalendarView to create an event for a specific date.

-(void)setEventForDate:(NSDate *)date isHoliday:(BOOL)holiday withTitle:(NSString *)title{

   // NSLog(@"Date received for event %@", date);

    for (DateButton *dateButton in self.dateButtons) {
        if (dateButton.date) {
            NSLog(@"%@", dateButton.date);

            if ([date isEqualToDate:dateButton.date]) {
                NSLog(@"Matched date %@", dateButton.date);

                UIColor *eventColor;
                UIColor *textColor;

                if (holiday) {
                    eventColor = [UIColor grayColor];
                    textColor = [UIColor whiteColor];
                } else {
                    eventColor =[UIColor colorWithRed:0.557 green:0.137 blue:0.267 alpha:1];
                    textColor = [UIColor whiteColor];
                }

                UILabel *eventTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, dateButton.frame.size.height - 15, dateButton.frame.size.width, 15)];

                [eventTitle setNumberOfLines:0];
                [eventTitle setText:title];
                [eventTitle setTextColor: textColor];
                [eventTitle setBackgroundColor:eventColor];
                [eventTitle setAdjustsFontSizeToFitWidth:YES];
                [eventTitle setTextAlignment:NSTextAlignmentCenter];

                [dateButton addSubview:eventTitle];
            }

        }
    }
}

The trouble I am having is that the the view shows in the cell the day before the correct date.

For example, if date passed in is 10/20/2013, the UILabel appears in the cell for 10/19, even though the debugger shows that the dateButton is 10/20.

I've narrowed it down to onlyShowCurrentMonth. If set to YES, the view appears in the correct cell otherwise it shows up in the day before.

@sudhakar-448
Copy link

in this what is the date button ?

@sudhakar-448
Copy link

and what is the date buttons array?

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

2 participants