Adding a Progress View 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 IGProgressView™ 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 IG Framework File

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


In this topic


Displaying an IGProgressView – Code Example

Description

This code example illustrates how to create a radial progress indicator with a height and width of 200 pixels, and centered vertically and horizontally in the current device orientation. After which, it is added to a view.

Preview

Code

To start, the background color of the view controller’s view is set to white.

In Objective-C:

self.view.backgroundColor = [UIColor whiteColor];

In C#:

this.View.BackgroundColor = UIColor.White;

Next, using the initWithStyle: constructor, create an instance of the IGProgressView using the IGProgressViewStyleRadialIndeterminate style.

In Objective-C:

IGProgressView *progressView = [[IGProgressView alloc] initWithStyle:IGProgressViewStyleRadialIndeterminate];
progressView.frame = CGRectMake((self.view.bounds.size.width / 2) - 100, (self.view.bounds.size.height / 2) - 100, 200, 200);
progressView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleBottomMargin;
[self.view addSubview:progressView];

In C#:

IGProgressView progressView = new IGProgressView (IGProgressViewStyle.IGProgressViewStyleRadialIndeterminate);
progressView.Frame = new RectangleF((this.View.Bounds.Size.Width / 2) - 100, (this.View.Bounds.Size.Height / 2) - 100, 200, 200);
progressView.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin|UIViewAutoresizing.FlexibleBottomMargin|UIViewAutoresizing.FlexibleLeftMargin|UIViewAutoresizing.FlexibleRightMargin;
this.View.Add(progressView);

Next, configure the height and width to equal 200 and center the progress in the center of the view.

In Objective-C:

progressView.frame = CGRectMake((self.view.bounds.size.width / 2) - 100, (self.view.bounds.size.height / 2) - 100, 200, 200);

In C#:

progressView.Frame = new RectangleF((this.View.Bounds.Size.Width / 2) - 100, (this.View.Bounds.Size.Height / 2) - 100, 200, 200);

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

In Objective-C:

progressView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleBottomMargin;

In C#:

progressView.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin|UIViewAutoresizing.FlexibleBottomMargin|UIViewAutoresizing.FlexibleLeftMargin|UIViewAutoresizing.FlexibleRightMargin;

Finally, add the progress to the view.

In Objective-C:

 [self.view addSubview:progressView];

In C#:

this.View.Add(progressView);

Related Content

Topics

The following topic provides additional information related to this topic.

Topic

Purpose

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