How to remove selected date highlight in iOS

3 posts, 0 answers
  1. Dev
    Dev avatar
    9 posts
    Member since:
    Apr 2018

    Posted 03 May 2018 Link to this post

    I have a RadCalendar in Week view mode that I'm using to allow users to jump to dates in an events list. The calendar displays indicators for dates that have events in the list. On iOS, if a user taps a date that does not have an indicator, a black highlight appears (see screenshot #1). Tapping a date with an indicator, does not show a highlight (see screenshot #2). On Android, there is no highlight no matter which dates the user taps on (i.e. always looks like screenshot #2).

    How can I get rid of the highlight on iOS?

  2. Nikolay
    Admin
    Nikolay avatar
    37 posts

    Posted 08 May 2018 Link to this post

    Hello,

    Removing the selected date highlight of the iOS calendar is currently not exposed in Xamarin.Forms. However you can achieve that by creating a custom CalendarRenderer where you will have access to the native control and you can change the shape property of the calendar cell.

    I'm posting simple implementation of CustomCalendarRenderer that should solve your problem:

    public class CustomCalendarRenderer : CalendarRenderer
    {
        protected override CalendarDelegate CreateCalendarDelegateOverride()
        {
            return new CustomCalendarDelegate();
        }
    }
     
    public class CustomCalendarDelegate : CalendarDelegate
    {
        public override TKCalendarCell ViewForCellOfKind(TKCalendar calendar, TKCalendarCellType cellType)
        {
            if (cellType == TKCalendarCellType.Day)
            {
                CustomDayCell cell = new CustomDayCell();
                return cell;
            }
     
            return base.ViewForCellOfKind(calendar, cellType);
        }
    }
     
    public class CustomDayCell : TKCalendarDayCell
    {
        public override void UpdateVisuals()
        {
            base.UpdateVisuals();
            this.Style.Shape = null;
        }
    }


    I hope I've been helpful.

    Regards,
    Nikolay
    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
  3. Dev
    Dev avatar
    9 posts
    Member since:
    Apr 2018

    Posted 11 May 2018 in reply to Nikolay Link to this post

    Perfect. Works beautifully. Thanks.
Back to Top