I was way late on reading-up about IBInspectable
and IBDesignable
, so I started playing around with them. One thing led to another, which led to this thing. Turns out they are pretty awesome time savers and I/we/you/me should use them more often! So, for those of you who want to learn, or are looking for a UIActivityIndicatorView
that can take a custom image, here is…
A UIActivityIndicatorView
-inspired UIView
that allows you to set a custom image for the indicator. It takes advantage ofIBInspectable
and IBDesignable
attributes (available since XCode 6,) which allows you to configure this indicator with your custom image and preview it in Interface Builder — including color changes — without having to first compile and run the app.
-
Drop a
UIView
into your storyboard and then change its class toDizzyActivityIndicatorView
-
You can then configure its image and
UIActivityIndicatorView
style attributes, likeisAnimating
andhidesWhenStopped
-
You can even change the color, and see it change in Interface Builder!
-
The DizzySample application target provides a concrete example of how to use this class.
It's one file, so it's easiest to just drop DizzyActivityIndicatorView.swift
into your XCode project via a clone+copy or even a submodule reference (but if you're really hunkering for some kind of dependency manager support, then file an issue and let's work together on it!)
Thanks to @fabb for this gist: https://gist.github.com/fabb/007d30ba0759de9be8a3, which helped to make adding color support an easy task.