O'Reilly logo

Programming iOS 4 by Matt Neuburg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

UIProgressView

A progress view (UIProgressView) is a “thermometer,” graphically displaying a percentage. It is often used to represent a time-consuming process during which the percentage of completion is known (if the percentage of completion is unknown, you’re more likely to use an activity indicator), but it might also be used to represent a fairly static percentage. For example, in one of my apps, I use a progress view to show the current position within the song being played by the built-in music player; in another app, which is a card game, I use a progress view in reverse, as it were, to show how many cards are left in the deck.

A progress view comes in a style, its progressViewStyle; if the progress view is created in code, you’ll set its style with initWithProgressViewStyle:. Your choices are:

  • UIProgressViewStyleDefault
  • UIProgressViewStyleBar

The latter is intended for use in a UIBarButtonItem, as the title view of a navigation item, and so on.

A progress view

Figure 25-2. A progress view

The height (the narrow dimension) of a progress view is generally not up to you; it’s determined by the progress view’s style. Changing a progress view’s height has no visible effect on how the thermometer is drawn and is not a good idea.

The fullness of the thermometer is the progress view’s progress property. This is a value between 0 and 1, inclusive; obviously, you’ll need to do some elementary arithmetic ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required