This is a migrated thread and some comments may be shown as answers.

Calendar Styling

1 Answer 53 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Robert
Top achievements
Rank 2
Robert asked on 09 May 2016, 02:19 PM

Hi, 

I have been using the updateVisualsForCell: method and picking apart the documentation for clues to achieve the desired results for my calendar styling however I cannot seem to get it how I want it to be and wanted to make sure that the control is not limiting me to achieve the results I want. I have attached what I currently have and what I desire. Is there a way for me to get the weekend highlighting to extend into the dayNameCell's for "SAT" and "SUN", and is there a way for me to add the text "CW" (stands for calendar week) in the column above the week numbers where the day names are?

Another styling adjustment is to have the current week number highlighted in a different colour. 

Are these possible with the control and if so could you provide some guidance?

Regards,

Robert

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Adrian
Telerik team
answered on 10 May 2016, 02:02 PM
Hi, Robert,

Thank you for contacting us.
You can easily highlight the day name cells for the weekends by their label's text. Consider the code below:
if ([cell isKindOfClass:[TKCalendarDayNameCell class]]) {
        //...
        if ([cell.label.text isEqualToString:@"Sat"] || [cell.label.text isEqualToString:@"Sun"]) {
            cell.style.backgroundColor = [UIColor groupTableViewBackgroundColor];
        }
    }

The cell that is above the week number is not a TKCalendarCell. It is just an offset and currently it is not possible to write anything there. I logged this in our feedback portal. We will consider implementing this in a future version.
To highlight the week number cell of current week you should check if the week which cell will be rendered is today's week as shown below:
if ([cell isKindOfClass:[TKCalendarWeekNumberCell class]]) {
        //...
        NSDateComponents *comps = [self.calendarView.calendar components:NSWeekOfYearCalendarUnit fromDate:[NSDate new]];
        NSInteger weekNumber = comps.weekOfYear;
        if (weekNumber == cell.label.text.integerValue) {
            cell.style.backgroundColor = [UIColor groupTableViewBackgroundColor];
        }
    }

I hope this helps. If you have further questions do not hesitate to contact us.

Regards,
Adrian
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Calendar
Asked by
Robert
Top achievements
Rank 2
Answers by
Adrian
Telerik team
Share this question
or