Configuring the Title Bar
Send Feedback

Glossary Item Box

Topic Overview

Purpose

This topic provides an introductory overview of customizing the title bar on the IGCalendarView™ control and demonstrates its configuration using a code example.

In this topic


Introduction

Title bar summary

The IGCalendarView provides an optional title bar that is customizable for each view:

  • Year
  • Month
  • Day

To adjust the visibility of the title bar, set the displayTitleBar property to YES or NO. The back button on the title bar is also optional; to adjust the visibility of the back button on the title bar, set the displayBackButton to YES or NO.

Implement the IGCalendarViewDelegate and use the calendarView:titleLabelForDate:forDisplayType: method to return a custom string to customize the title bar label. Additionally, you can customize the back button label using the calendarView:titleForBackButtonForDate:forDisplayType: method to return a custom string.

Implement IGCalendarViewDelegate using the right button, reserved for this purpose; customize its text using the calendarView:titleForRightTitleBarButtonFor: method; and handle the button tapped event using the calendarView:rightTitleBarButtonTappedFor:.


Customizing the Title Bar – Code Example

Description

The code below creates an instance of the IGCalendarView and customizes the title bar label.

Preview

The following image is a preview of the code example.

Prerequisites

This code example requires the inclusion of the IG framework, detail about how to add this framework can be found in the Adding the IG Framework File topic.

Code

In Objective-C:

@interface igViewController () <IGCalendarViewDelegate>
@end
@implementation igViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    IGCalendarView *calendar = [[IGCalendarView alloc] initWithFrame:self.view.bounds];
    calendar.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
    calendar.delegate = self;
    [self.view addSubview:calendar];
}
- (NSString *)calendarView:(IGCalendarView *)calView titleLabelForDate:(NSDate *)date forDisplayType:(IGCalendarViewDisplayType)displayType
{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    switch(displayType)
    {
        case IGCalendarViewDisplayTypeYear:
            dateFormatter.dateFormat = @"yyyy";
            break;
        case IGCalendarViewDisplayTypeMonth:
            dateFormatter.dateFormat = @"MMMM (QQQQ)";
            break;
        case IGCalendarViewDisplayTypeDay:
            dateFormatter.dateFormat = @"MMMM d, yyyy (QQQQ)";
            break;
    }
    return [dateFormatter stringFromDate:date];
}
@end

In C#:

public class CalendarDelegate : IGCalendarViewDelegate
{
      public override string ResolveTitleLabel (IGCalendarView calView, NSDate date, IGCalendarViewDisplayType displayType)
      {
            NSDateFormatter dateFormatter = new NSDateFormatter();
            switch(displayType)
            {
                  case IGCalendarViewDisplayType.IGCalendarViewDisplayTypeYear:
                  dateFormatter.DateFormat = @"yyyy";
                  break;
                  case IGCalendarViewDisplayType.IGCalendarViewDisplayTypeMonth:
                  dateFormatter.DateFormat = @"MMMM (QQQQ)";
                  break;
                  case IGCalendarViewDisplayType.IGCalendarViewDisplayTypeDay:
                  dateFormatter.DateFormat = @"MMMM d, yyyy (QQQQ)";
                  break;
            }
            return dateFormatter.StringFor(date);
      }
}
public partial class CalendarTitleBar_CSViewController : UIViewController
{
      public CalendarTitleBar_CSViewController ()
      {
      }
      public override void ViewDidLoad ()
      {
            base.ViewDidLoad ();
            
            IGCalendarView calendar = new IGCalendarView ();
            calendar.Frame = this.View.Bounds;
            calendar.Delegate = new CalendarDelegate ();
            this.View.Add (calendar);
      }
}

Related Content

Topics

The following topic provides additional information related to this topic.

Topic

Purpose

The topics in this group cover enabling, configuring, and using the IGCalendarView control’s supported features.