Adding the Linear Gauge to a View
Send Feedback

Glossary Item Box

Topic Overview

Purpose

This topic explains, with a code example how to create a basic instance of the IGLinearGaugeView™ control and display it on a view.

Required background

The following table lists the prerequisite topic required to understanding this topic.

Topic

Purpose

Adding the Chart Framework File

This topic explains how to add the Chart framework file to a project.


In this topic


Displaying an IGLinearGaugeView – Code Example

Description

This code example illustrates how to create and add a (default) horizontally oriented linear gauge with the value property set to 82 to a view.

Preview

Code

To start, initialize a frame to serve as the linear gauge’s size and position.

In Objective-C:

CGRect gaugeRect = self.view.bounds;
gaugeRect.size.height = 250;
gaugeRect.origin.y = (self.view.bounds.size.height / 2) - 125;

In C#:

RectangleF gaugeRect = this.View.Bounds;
gaugeRect.Height = 250;
gaugeRect.Y = (this.View.Bounds.Height / 2) - 125;

Next, create an instance of the linear gauge using the dimensions of the frame.

In Objective-C:

IGLinearGaugeView *gauge = [[IGLinearGaugeView alloc] initWithFrame:gaugeRect];

In C#:

IGLinearGaugeView gauge = new IGLinearGaugeView ();
gauge.Frame = gaugeRect;

Next, set the auto-resizing mask to allow the linear gauge to float in the center of the current device orientation without requiring a size adjustment.

In Objective-C:

gauge.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin;

In C#:

gauge.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleBottomMargin;

Set the value property of the linear gauge to 82.

In Objective-C:

gauge.value = 82;

In C#:

gauge.Value = 82;

Finally, add the linear gauge to the view.

In Objective-C:

 [self.view addSubview:gauge];

In C#:

this.View.Add(gauge);

Related Content

Topics

The following topic provides additional information related to this topic.

Topic

Purpose

This topic provides a conceptual overview of the IGLinearGaugeView control and its key features.