iOS Developer Library

Developer

UIKit Framework Reference UIActivityIndicatorView Class Reference

Options
Deployment Target:

On This Page
Language:

UIActivityIndicatorView

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 YEStrue.

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.

Inheritance


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 2.0 and later.
  • Initializes and returns an activity-indicator object.

    Declaration

    Swift

    init!(activityIndicatorStyle style: UIActivityIndicatorViewStyle)

    Objective-C

    - (instancetype)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.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Starts the animation of the progress indicator.

    Declaration

    Swift

    func startAnimating()

    Objective-C

    - (void)startAnimating

    Discussion

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

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Stops the animation of the progress indicator.

    Declaration

    Swift

    func stopAnimating()

    Objective-C

    - (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 NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Returns whether the receiver is animating.

    Declaration

    Swift

    func isAnimating() -> Bool

    Objective-C

    - (BOOL)isAnimating

    Return Value

    YEStrue if the receiver is animating, otherwise NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    var hidesWhenStopped: Bool

    Objective-C

    @property(nonatomic) BOOL hidesWhenStopped

    Discussion

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

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

Data Types

  • The visual style of the progress indicator.

    Declaration

    Swift

    enum UIActivityIndicatorViewStyle : Int { case WhiteLarge case White case Gray }

    Objective-C

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

    Constants

    • WhiteLarge

      UIActivityIndicatorViewStyleWhiteLarge

      The large white style of indicator.

      Available in iOS 2.0 and later.

    • White

      UIActivityIndicatorViewStyleWhite

      The standard white style of indicator (the default).

      Available in iOS 2.0 and later.

    • Gray

      UIActivityIndicatorViewStyleGray

      The standard gray style of indicator.

      Available in iOS 2.0 and later.

    Discussion

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

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.