Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode6: IBDesignable and IBInspectable with Objective-C

I have an Objective-C UI component that I'd like to make inspectable in Interface Builder with Xcode 6. Swift has the @IBDesignable and @IBInspectable declaration attributes. Are they available also in Objective-C? How are they used?

like image 764
mxb Avatar asked Jun 28 '14 10:06

mxb


People also ask

What is IBDesignable and IBInspectable?

IBDesignable is user defined run time. Mean that if any IBDesignable view is rendered on the storyboard, you will find the view and change the value of the IBInspectable property, this will directly reflect on the storyboard without running the app. IBInspectable is run time property, this works as key coding value.


2 Answers

Code example:

#import <UIKit/UIKit.h>
IB_DESIGNABLE
@interface LOLView : UIView
@property (nonatomic) IBInspectable UIColor *someColor; 
@end
like image 138
Adam Waite Avatar answered Oct 24 '22 02:10

Adam Waite


The equivalents are IB_DESIGNABLE and IBInspectable—see the documentation for Objective C examples.

Also, this year's WWDC video "What's New in Interface Builder" has its examples in Swift, but the presenter also mentions the Objective C equivalents in passing.

like image 77
Matt Gibson Avatar answered Oct 24 '22 01:10

Matt Gibson