Customizing Scale Labels
Send Feedback

Glossary Item Box

Topic Overview


This topic provides a conceptual overview of customizing scale labels on the IGLinearGaugeView™ control and demonstrates how to configure it using a code example.

In this topic


Custom labels summary

The scale labels on the IGLinearGaugeView control are extremely flexible allowing you to present some highly specialized information via customization using the control’s linearGaugeView:formatStringForValue: delegate method. The method provides the IGLinearGaugeView calling the method with the label value to format and returns an NSString containing the text of the new label.

Customizing Scale Labels – Code Example


The code example uses the IGLinearGaugeViewDelegate to implement the linearGaugeView:formatStringForValue: delegate method for adding a percent symbol to the label formatting.


This code example requires the inclusion of the Chart framework; details about how to add this framework are available in the Adding the Chart Framework File topic.



In Objective-C:

@interface igViewController () <IGLinearGaugeViewDelegate>
@implementation igViewController
- (void)viewDidLoad
    [super viewDidLoad];
    CGRect gaugeRect = self.view.bounds;
    gaugeRect.size.height = 250;
    gaugeRect.origin.y = (self.view.bounds.size.height / 2) - 125;
    IGLinearGaugeView *gauge = [[IGLinearGaugeView alloc] initWithFrame:gaugeRect];
    gauge.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin;
    gauge.fontBrush = [[IGBrush alloc] initWithR:0 andG:0 andB:0 andA:1];
    gauge.interval = 20;
    gauge.value = 82;
    gauge.delegate = self;
    [self.view addSubview:gauge];
- (NSString *)linearGaugeView:(IGLinearGaugeView *)linearGaugeView formatStringForValue:(double)labelValue
    return [NSString stringWithFormat:@"%.0f%%", labelValue];

In C#:

public partial class LinearGaugeScaleLabels_CSViewController : UIViewController
      public LinearGaugeScaleLabels_CSViewController ()
      public override void ViewDidLoad ()
            base.ViewDidLoad ();
            RectangleF gaugeRect = this.View.Bounds;
            gaugeRect.Height = 250;
            gaugeRect.Y = (this.View.Bounds.Height / 2) - 125;
            IGLinearGaugeView gauge = new IGLinearGaugeView ();
            gauge.Frame = gaugeRect;
            gauge.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleBottomMargin;
            gauge.FontBrush = new IGBrush (UIColor.Black);
            gauge.Interval = 20;
            gauge.Value = 82;
            gauge.Delegate = new LinearGaugeDelegate ();
            this.View.Add (gauge);
public class LinearGaugeDelegate : IGLinearGaugeViewDelegate
      public override string ResolveFormatString (IGLinearGaugeView linearGaugeView, double labelValue)
            return String.Format ("{0}%", labelValue);

Related Content


The following topic provides additional information related to this topic.



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