Xcode Creating Custom Controls in Interface Builder with @IBDesignable


It became much easier to create custom controls in Interface Builder with the introduction of the @IBDesignable and @IBInspectable directives in Swift. Developers can now build rich, complex, fully animated controls using just a few extra lines of code. I'm surprised by how many developers have yet to fully embrace this feature, and I frequently find that adding just a few of lines of code to existing classes can make them so much easier to work with.

Note that these features are also available in Objective-C and are a great way of breathing life into old classes. The syntactic equivalents in Objective-C are IB_DESIGNABLE and IBInspectable, but for now I'll be concentrating on examples in Swift.