Header

3 Sep 20203 minutes to read

You can customize the header of the Schedule using HeaderStyle and HeaderHeight property in SFSchedule.

Header Height

You can customize the height for the Header in Schedule using HeaderHeight in schedule.

schedule.HeaderHeight = 50;

Appearance

You can change the header format and style using HeaderStyle property in schedule.

You can change the background color,text style and text color using properties such as BackgroundColor, TextStyle, TextColor of Header using HeaderStyle property in schedule.

SFHeaderStyle headerStyle = new SFHeaderStyle();
headerStyle.BackgroundColor = UIColor.FromRGB(251, 211, 201);
headerStyle.TextStyle = UIFont.SystemFontOfSize(15,UIFontWeight.Bold);
headerStyle.TextColor=UIColor.White;
schedule.HeaderStyle = headerStyle;

Customize Font Appearance

You can change the appearance of Font by setting the TextStyle property of HeaderStyle property in Schedule.

headerStyle.TextStyle = UIFont.FromName("Lobster-Regular",15);

Refer this to configure the custom fonts in Xamarin.iOS.

Loading Custom Headers

You can collapse the default header of schedule by setting HeaderHeight property of SFSchedule as 0. Instead you can use your own custom header for it. While navigating views in schedule, text labels available in the header will be changed based on it visible dates, so while using custom header , respective text value can be obtained from the VisibleDatesChanged event of SFSchedule.

//triggering visible dates changed event.
schedule.VisibleDatesChanged += Schedule_VisibleDatesChanged;

...

private void Schedule_VisibleDatesChanged(object sender, VisibleDatesChangedEventArgs e)
{
    //to get visible dates index value.
    int visibleDatesIndex = 0;
    var headerString = string.Empty;
    if (schedule.ScheduleView == SFScheduleView.SFScheduleViewMonth)
    {
        visibleDatesIndex = 8;//to get current month visible dates.
    }
    else
    {
        visibleDatesIndex = 0;
    }
    NSDate date = e.VisibleDates.GetItem<NSDate>((nuint)visibleDatesIndex);
    NSDateFormatter dateFormat = new NSDateFormatter();
    dateFormat.DateFormat = "MMMM YYYY";
    headerString = dateFormat.ToString(date);
}

You can get the complete sample for customizing the Header of Schedule here

Header Date Format

You can customize the date format of SFSchedule Header by using ScheduleDateHeaderFormat property of SFSchedule.

//Creating instance of Schedule
SFSchedule schedule = new SFSchedule();
//Customizing date format
schedule.ScheduleDateHeaderFormat = (NSString)"LLL yy";

Header Tapped Event

You can handle single tap action of Header by using HeaderTapped event of SFSchedule. This event will be triggered when the Header is Tapped. This event contains HeaderTappedEventArgs argument which holds Date details in it.

//Creating  new instance of Schedule
SFSchedule schedule = new SFSchedule();
schedule.HeaderTapped += Handle_HeaderTapped;

...

void Handle_HeaderTapped(object sender, HeaderTappedEventArgs e)
{
    var date = e.Date;
}