Looking for some help on the best way 开发者_JAVA技巧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.
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.
精彩评论