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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.
回答2:
Code example:
#import <UIKit/UIKit.h>
IB_DESIGNABLE
@interface LOLView : UIView
@property (nonatomic) IBInspectable UIColor *someColor;
@end