Inherits From:
NSView : NSResponder : NSObject
Conforms To:
NSCoding (NSResponder)
NSObject (NSObject)
Declared In:
AppKit/NSProgressIndicator.h
NSProgressIndicator is a subclass of NSView. To display a progress indicator, your application creates a window and adds the progress indicator as a subview of the window's content view or any subview. You can create a progress indicator programmatically and initialize it with the initWithFrame:
method. However, you normally use Interface Builder to create and initialize a progress indicator and to install it in an application view.
For an indeterminate progress indicator, you invoke startAnimation:
to start the animation (the spinning of the barber pole) and stopAnimation:
when the task is complete. By default, the delay between animation steps is one twelfth of a second (5.0/60.0). You can change the animation delay by invoking setAnimationDelay:
. Setting the delay to a double value larger than the default value will slow the animation, while setting the delay to a smaller value will speed it up.
Instead of invoking startAnimation:
and stopAnimation:
, you can control an indeterminate progress indicator directly by sending the animate:
message. Each time you invoke animate:
, the animation advances by one step. You can speed up or slow down the animation by varying how often you invoke animate:
. Like other views, a progress indicator redisplays itself on each pass through the event loop, if needed. To ensure immediate redrawing, however, you can invoke the displayIfNeeded
method (inherited from NSView) each time you invoke animate:
.
By default, a progress indicator is indeterminate. Your can specify a determinate progress indicator when you set up the view with Interface Builder, or you can use code like the following to change the default value programmatically:
[myProgressIndicatorView setIndeterminate:FALSE];
For a determinate progress indicator, you invoke the incrementBy:
method to advance the progress bar. By default, a determinate progress indicator goes from 0.0 to 100.0. You can increment by any amount, but if you vary the increment too widely, progress may appear uneven or jerky. You typically choose an increment value that evenly divides 100.0. For example, you might invoke incrementBy:
50 times, incrementing by 2.0 each time, to draw the complete progress bar. To modify the default range of 0.0 to 100.0, you can invoke setMinValue:
to modify the minimum value and setMaxValue:
to modify the maximum value.
After each invocation of incrementBy:
, you can invoke the displayIfNeeded
method to ensure immediate redrawing.
You can display progress indicators of different sizes by varying the frame size. However, the default size is designed to provide the best results. By default, a progress indicator is drawn with a bezeled frame, but you can use the setBezeled:
method to modify the bezeled-frame setting.
A progress indicator is drawn with colors based on the user's current color scheme. When the user changes the color scheme, the color of the progress indicator changes automatically to match the new scheme.
animate:
(id)sender
For an indeterminate progress indicator, advances the progress animation by one step. For a determinate progress indicator, does nothing. Your application uses this method to control animation directly (as opposed to invoking startAnimation:
and stopAnimation:
for automatic animation). The more often you invoke animate:
, the faster the animation progresses.
The xx method only invalidates the progress indicator so it will be redrawn the next time through the event loop. To ensure immediate redrawing, invoke the displayIfNeeded
method.
See also:
- animationDelay
, - setAnimationDelay:
animationDelay
For an indeterminate progress indicator, returns the delay, in seconds, between animation steps. By default, the animation delay is set to one twelfth of a second (5.0/60.0). A determinate progress indicator does not use the animation delay value.
See also:
- animate:
doubleValue
For a determinate progress indicator, returns a value that indicates the current extent of the progress bar. For example, a determinate progress indicator goes from 0.0 to 100.0 by default. If the progress bar has advanced half way across the view, the value returned by doubleValue
would be 50.0. An indeterminate progress indicator does not use this value.
See also:
- incrementBy:
, - setDoubleValue:
incrementBy:
(double)delta
For a determinate progress indicator, you invoke incrementBy:
to advance the progress bar by delta. For example, if you want to advance a progress bar from 0.0 to 100.0 in twenty steps, you would invoke incrementBy:
twenty times with a delta value of 5.0.
See also:
- doubleValue
initWithFrame:
(NSRect)frameRect
Initializes a newly allocated NSProgressIndicator with frameRect as its frame rectangle. This method is the designated initializer for the NSProgressIndicator class. It calls the initWithFrame:
method of its superclass, NSView, then performs initialization specific to the outline view. It returns self
.
It's usually more convenient to use Interface Builder, which allows you to create an NSProgressIndicator and embed it in the superview of your choice.
isBezeled
Returns YES if the NSProgressIndicator's frame has a three-dimensional bezel.
See also:
- setBezeled:
isIndeterminate
Returns YES if the NSProgressIndicator is indeterminate. An indeterminate progress indicator displays a "barber pole" that spins until the task is complete. A determinate progress indicator draws a three-dimensional bar from left to right as the task progresses.
See also:
- setIndeterminate:
maxValue
For a determinate progress indicator, returns the maximum value for the progress bar. By default, a determinate progress indicator goes from 0.0 to 100.0, so the value returned would be 100.0. An indeterminate progress indicator does not use this value.
See also:
- minValue
, - setMaxValue:
minValue
For a determinate progress indicator, returns the minimum value for the progress bar. By default, a determinate progress indicator goes from 0.0 to 100.0, so the value returned would be 0.0. An indeterminate progress indicator does not use this value.
See also:
- maxValue
, - setMinValue:
setAnimationDelay:
(NSTimeInterval)delay
Sets the delay, in seconds, between animation steps for an indeterminate progress indicator. By default, the animation delay is set to one twelfth of a second (5.0/60.0). Setting the delay to a double value larger than 5.0/60.0 will slow the animation, while setting the delay to a smaller value will speed it up. A determinate progress indicator does not use the animation delay value.
setBezeled:
(BOOL)flag
Sets whether the NSProgressIndicator's frame has a three-dimensional bezel.
See also:
- isBezeled
setDoubleValue:
(double)doubleValue
Sets the value that indicates the current extent of the progress bar. An indeterminate progress indicator does not use this value.
See also:
- doubleValue
, - incrementBy:
, - setMaxValue:
, - setMinValue:
setIndeterminate
:(BOOL)flag
Sets whether the NSProgressIndicator is indeterminate.
See also:
- isIndeterminate
setMaxValue:
(double)newMaximum
Specifies the maximum value for the progress bar. An indeterminate progress indicator does not use this value.
See also:
- maxValue
setMinValue:
(double)newMinimum
Specifies the minimum value for the progress bar. An indeterminate progress indicator does not use this value.
See also:
- minValue
setUsesThreadedAnimation:
(BOOL)flag
Sets whether the receiver implements animation of the progress indicator in a separate thread. If the application becomes multithreaded as a result of an invocation of this method, the application's performance could become noticeably slower.
See also:
- usesThreadedAnimation
startAnimation:
(id)sender
For an indeterminate progress indicator, starts the animation, which causes the barber pole to start spinning. For a determinate progress indicator, does nothing.
See also:
- animationDelay, - stopAnimation:
stopAnimation:
(id)sender
For an indeterminate progress indicator, stops the animation, which causes the barber pole to stop spinning. For a determinate progress indicator, does nothing.
See also:
- animationDelay, - startAnimation:
usesThreadedAnimation
Returns whether the receiver implements the animation of the progress indicator in a separate thread.
See also:
- setUsesThreadedAnimation: