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?
我有一个Objective-C UI组件,我想用Xcode 6在Interface Builder中进行检查。Swift具有@IBDesignable和@IBInspectable声明属性。在Objective-C中也有吗?他们是如何使用?
2 个解决方案
#1
68
The equivalents are IB_DESIGNABLE and IBInspectable—see the documentation for Objective C examples.
对应的是IB_DESIGNABLE和ibinspectable——查看Objective - C示例的文档。
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.
另外,今年的WWDC视频“界面构建器的新功能”在Swift中也有它的例子,但是演示者也提到了通过的Objective C。
#2
66
Code example:
代码示例:
#import <UIKit/UIKit.h>
IB_DESIGNABLE
@interface LOLView : UIView
@property (nonatomic) IBInspectable UIColor *someColor;
@end
#1
68
The equivalents are IB_DESIGNABLE and IBInspectable—see the documentation for Objective C examples.
对应的是IB_DESIGNABLE和ibinspectable——查看Objective - C示例的文档。
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.
另外,今年的WWDC视频“界面构建器的新功能”在Swift中也有它的例子,但是演示者也提到了通过的Objective C。
#2
66
Code example:
代码示例:
#import <UIKit/UIKit.h>
IB_DESIGNABLE
@interface LOLView : UIView
@property (nonatomic) IBInspectable UIColor *someColor;
@end