Some random notes about creating designable custom views in Xcode:
- Adding the symbol IB_DESIGNABLE to the view declaration just before the @interface declaration of your view in the view header will mark your view as designable in Interface Builder; the view will be rendered in your view.
- Each property that is declared with the IBInspectable keyword will then be inspectable and can be set in Interface Builder.
- The properties that can be inspected this way are: “boolean, integer or floating point number, string, localized string, rectangle, point, size, color, range, and nil.”
- The preprocessor macro TARGET_INTERFACE_BUILDER is defined to be true if compiled to run on Interface Builder. Use this to short circuit logic which shouldn’t run on IB.
- Likewise, the method – (void)prepareForInterfaceBuilder; is called (if present) on initializing the class only if it is loaded in Interface Builder.
- You can debug your views within Interface Builder; Apple documents the process here.