0

Looking for some help on the best way to create a custom UIActivityIndicator. I think that ideally, it should be a SubClass of UIActivityIndicator so that we can easily distribute it to other apps that might want to take advantage of it, and easily drag and drop where it should go in Interface Builder.

As an example, the UIActivityIndicator on the TMZ app seems to be custom, but being new to Objective-C and over Xcode development, and I'm struggling with a place to start and the best most efficient approach. Has this proverbial "wheel" already been created?

Thanks in advance for your time.

Aurum Aquila
  • 9,126
  • 4
  • 25
  • 24
mrpeepers
  • 33
  • 5

1 Answers1

1

UIActivityIndicator is not designed to be customized, so subclassing it won't do you much good. But it is a simple UI element which can be written from scratch in an hour. Since you don't want it to respond to events, make it a subclass of UIView and set userInteractionEnabled to NO. The downside is that IB won't show a nice preview as with UIActivityIndicator.

Reusing such a class is easy: just add the interface/implementation files to an Xcode project and #import the header.

UIActivityIndicator works like an animated GIF, displaying a series of images. Of course, you can do the same or you can just animate transform property of a sublayer to make it spin.

Costique
  • 23,712
  • 4
  • 76
  • 79
  • Thanks Costique. Is there any way, another route or method perhaps, where something like this could be integrated within Interface Builder? Thanks again for your response! – mrpeepers Jan 28 '11 at 16:05
  • AFAIK, no. Unfortunately, IB doesn't support user plugins for iOS xibs. – Costique Jan 29 '11 at 06:23
  • Now I'm actually using Core Animation to accomplish this task. Still working on it, however. – mrpeepers Mar 23 '11 at 21:15