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

How to customize RadCalendar month title in iOS?

2 Answers 110 Views
Calendar - Xamarin.iOS
This is a migrated thread and some comments may be shown as answers.
Dev
Top achievements
Rank 1
Dev asked on 02 May 2018, 06:47 PM

I've created a custom calendar delegate for iOS as described here (https://docs.telerik.com/devtools/xamarin/controls/calendar/styling/custom-renderers/calendar-customrenderers-ios), and I'm trying to use it customize the calendar's month title cell. In my delegate, I have:

public override void UpdateVisualsForCell(TKCalendar calendar, TKCalendarCell cell)
{
    base.UpdateVisualsForCell(calendar, cell);
 
    switch (cell)
    {
       case TKCalendarMonthTitleCell monthTitleCell:
            FormatMonthTitleCell(monthTitleCell);
            break;
    }
}
 
private void FormatMonthTitleCell(TKCalendarMonthTitleCell monthTitleCell)
{
   monthTitleCell.Label.Text = "custom title";
}

 

I can see that the label's text is indeed changed when debugging, however, the title still displays as "[month] [year]". Is there something else that I need to be setting or hooking into in order to change the title?

2 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 07 May 2018, 08:39 AM
Hi,

You can use a custom cell as shown in this help topic -- Calendar Customizations. Basically, you need to override ViewForCellOfKind like this:

public override TKCalendarCell ViewForCellOfKind(TKCalendar calendar, TKCalendarCellType cellType)
        {
            if (cellType == TKCalendarCellType.Title)
            {
                CustomCell cell = new CustomCell();
                return cell;
            }
 
            return base.ViewForCellOfKind(calendar, cellType);
        }

and then provide your custom cell:

public class CustomCell : TKCalendarTitleCell
    {
        public CustomCell()
        {
        }
 
        public override void UpdateVisuals()
        {
            base.UpdateVisuals();
            this.Label.Text = "custom label";
        }
    }


Best regards,
Ves
Progress 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
0
Dev
Top achievements
Rank 1
answered on 11 May 2018, 08:43 PM
Perfect. Works beautifully. Thanks.
Tags
Calendar - Xamarin.iOS
Asked by
Dev
Top achievements
Rank 1
Answers by
Ves
Telerik team
Dev
Top achievements
Rank 1
Share this question
or