UIActivityIndicatorView Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 2.0 and later.
Companion guide
Declared in
UIActivityIndicatorView.h
Related sample code

Overview

Use an activity indicator to show that a task is in progress. An activity indicator appears as a “gear” that is either spinning or stopped.

You control when an activity indicator animates by calling the startAnimating and stopAnimating methods. To automatically hide the activity indicator when animation stops, set the hidesWhenStopped property to YES.

Starting in iOS 5.0, you can set the color of the activity indicator by using the color property.

For more information about appearance and behavior configuration, see “Activity Indicators”.

Tasks

Initializing an Activity Indicator

Managing an Activity Indicator

Configuring the Activity Indicator Appearance

Properties

activityIndicatorViewStyle

The basic appearance of the activity indicator.

@property UIActivityIndicatorViewStyle activityIndicatorViewStyle
Discussion

See UIActivityIndicatorStyle for the available styles. The default value is UIActivityIndicatorViewStyleWhite.

Availability
  • Available in iOS 2.0 and later.
Related Sample Code
Declared In
UIActivityIndicatorView.h

color

The color of the activity indicator.

@property (readwrite, nonatomic, retain) UIColor *color
Discussion

If you set a color for an activity indicator, it overrides the color provided by the activityIndicatorViewStyle property.

Availability
  • Available in iOS 5.0 and later.
Declared In
UIActivityIndicatorView.h

hidesWhenStopped

A Boolean value that controls whether the receiver is hidden when the animation is stopped.

@property BOOL hidesWhenStopped
Discussion

If the value of this property is YES (the default), the receiver sets its hidden property (UIView) to YES when receiver is not animating. If the hidesWhenStopped property is NO, the receiver is not hidden when animation stops. You stop an animating progress indicator with the stopAnimating method.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActivityIndicatorView.h

Instance Methods

initWithActivityIndicatorStyle:

Initializes and returns an activity-indicator object.

- (id)initWithActivityIndicatorStyle:(UIActivityIndicatorViewStyle)style
Parameters
style

A constant that specifies the style of the object to be created. See UIActivityIndicatorStyle for descriptions of the style constants.

Return Value

An initialized UIActivityIndicatorView object or nil if the object couldn’t be created.

Discussion

UIActivityIndicatorView sizes the returned instance according to the specified style. You can set and retrieve the style of a activity indicator through the activityIndicatorViewStyle property.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActivityIndicatorView.h

isAnimating

Returns whether the receiver is animating.

- (BOOL)isAnimating
Return Value

YES if the receiver is animating, otherwise NO.

Availability
  • Available in iOS 2.0 and later.
Related Sample Code
Declared In
UIActivityIndicatorView.h

startAnimating

Starts the animation of the progress indicator.

- (void)startAnimating
Discussion

When the progress indicator is animated, the gear spins to indicate indeterminate progress. The indicator is animated until stopAnimating is called.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActivityIndicatorView.h

stopAnimating

Stops the animation of the progress indicator.

- (void)stopAnimating
Discussion

Call this method to stop the animation of the progress indicator started with a call to startAnimating. When animating is stopped, the indicator is hidden, unless hidesWhenStopped is NO.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActivityIndicatorView.h

Constants

UIActivityIndicatorStyle

The visual style of the progress indicator.

typedef enum {
   UIActivityIndicatorViewStyleWhiteLarge,
   UIActivityIndicatorViewStyleWhite,
   UIActivityIndicatorViewStyleGray,
} UIActivityIndicatorViewStyle;
Constants
UIActivityIndicatorViewStyleWhiteLarge

The large white style of indicator.

Available in iOS 2.0 and later.

Declared in UIActivityIndicatorView.h.

UIActivityIndicatorViewStyleWhite

The standard white style of indicator (the default).

Available in iOS 2.0 and later.

Declared in UIActivityIndicatorView.h.

UIActivityIndicatorViewStyleGray

The standard gray style of indicator.

Available in iOS 2.0 and later.

Declared in UIActivityIndicatorView.h.

Discussion

You set the value of the activityIndicatorViewStyle property with these constants.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActivityIndicatorView.h