With this support, the developer can easily interact with the views and make any changes from the xib/storyboard files. It provides two keywords to allow live rendering in Xcode. IBDesignable and IBInspectable enable the developer to preview the custom class through xib.
How does it work?
@IBDesignable keyword is added as a prefix, along with classes, to let the interface builder know that the class instances are designable by themselves.
Custom properties used inside views and are declared as @IBInspectable. The user defined properties appear on the interface builder, along with built- in properties. Interface Builder can read and write the value of these properties, directly, in the inspector view. Developers can change those properties, directly, from xib rather than playing with codes.
This is simple. Try in swift or objective C applications. Make your ‘view classes’, visually, available for editing.
In objective C, add the tag IB_DESIGNABLE above the class interface section and declare your custom properties as IBInspectable.
Now, you can verify the identity inspector section of your xib/storyboard to get a list of custom properties that are editable.
Similarly, in Swift, first, you need to set the class as @IBDesignable, and then add the properties implemented with the didSet observer and mark as @IBInspectable, so that they can be accessed by Interface Builder.
After adding this, you will notice a label “designable” with the tag “up to date” in the identity inspector section.
The view can be modified from here and you can see the real-time magic.
By using the IBInspectable attribute, to declare variables as inspectable properties, you, actually, allow Interface Builder to quickly re–render your custom view as you change the values of these properties in the Attributes inspector. You can attach the IBInspectable attribute to any property in a class declaration, class extension, or category, for any type that is supported by the Interface Builder defined in runtime attributes: boolean, integer or floating point number, string, localized string, rectangle, point, size, color, range, and nil.
The New Xcode 6
The new Xcode 6 is recognized to go beyond incremental improvements. It gives the developers all the necessary tools, to help build, efficient, useful and magnificent applications. It is noted that live rendering is a huge win for all developers and is best suited for framework and target mode projects.
iOS and Swift Developer, RapidValue Solutions