Major and Minor Scales

SFDateTimeRangeNavigator displays major and minor scales at the top and bottom position of the control. You can also control its visibility using MajorScaleStyle.IsVisible and MinorScaleStyle.IsVisible properties.

Intervals

By default, best possible interval component will be chosen for both major and minor scales based on the available size of the view. For example, if the available space is sufficient to show only year labels without overlapping, interval will be displayed in years. However, you can also set specific interval values using Intervals property as demonstrated in the below code snippet.

  • c#
  • SFDateTimeRangeNavigator rangeNavigator = new SFDateTimeRangeNavigator ();
    
    NSMutableArray intervals = new NSMutableArray ();
    
    intervals.Add ((NSNumber)0);
    intervals.Add ((NSNumber)2);
    //Intervals: year = 0, Quarter = 1, Month = 2, Week = 3, Day = 4, Hour = 5
                
    rangeNavigator.Intervals = intervals;
    
    this.View.AddSubview(rangeNavigator);

    Interval support for major and minor scales in Xamarin.iOS DateTimeRangeNavigator

    Customization

    The MajorScaleStyle and MinorScaleStyle properties of SFDateTimeRangeNavigator are used to customize the appearance of ticks and labels.

  • c#
  • SFDateTimeRangeNavigator rangeNavigator = new SFDateTimeRangeNavigator ();
    
    rangeNavigator.MajorScaleStyle.TickColor = UIColor.Gray;
    rangeNavigator.MajorScaleStyle.TickWidth = 3;
    rangeNavigator.MajorScaleStyle.Position = SFRangeNavigatorScalePosition.Outside;
    rangeNavigator.MajorScaleStyle.ShowGridLines = true;
    rangeNavigator.MajorScaleStyle.GridLineColor = UIColor.Black;
    rangeNavigator.MajorScaleStyle.LabelFont = UIFont.SystemFontOfSize (8);
    rangeNavigator.MajorScaleStyle.LabelMargin = new UIEdgeInsets (10, 2, 2, 2);
    rangeNavigator.MajorScaleStyle.LabelTextColor = UIColor.Purple;
    rangeNavigator.MajorScaleStyle.LabelBorderWidth = 1;
    rangeNavigator.MajorScaleStyle.LabelBorderColor = UIColor.LightGray;
    rangeNavigator.MajorScaleStyle.LabelTextAlignment = UITextAlignment.Center;
    rangeNavigator.MajorScaleStyle.LabelBackgroundColor = UIColor.Clear;
    rangeNavigator.MajorScaleStyle.SelectedLabelTextColor = UIColor.White;
    rangeNavigator.MajorScaleStyle.SelectedLabelBackgroundColor = UIColor.Purple;
    
    rangeNavigator.MinorScaleStyle.Position = SFRangeNavigatorScalePosition.Inside;
    rangeNavigator.MinorScaleStyle.SelectedLabelTextColor = UIColor.Gray;
    
    rangeNavigator.MinorScaleStyle.ShowGridLines = false;
    
    this.View.AddSubview(rangeNavigator);

    Customizing the appearance of ticks and labels in Xamarin.iOS DateTimeRangeNavigator