Xcode6:IBDesignable 和 IBInspectable 与 Objective-C
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24465679/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode6: IBDesignable and IBInspectable with Objective-C
提问by mxb
I have an Objective-C UI component that I'd like to make inspectable in Interface Builder with Xcode 6. Swift has the @IBDesignableand @IBInspectabledeclaration attributes. Are they available also in Objective-C? How are they used?
我有一个Objective-C UI 组件,我想在带有Xcode 6 的Interface Builder 中进行检查。Swift 具有@IBDesignable和@IBInspectable声明属性。它们在 Objective-C 中也可用吗?它们是如何使用的?
回答by Adam Waite
Code example:
代码示例:
#import <UIKit/UIKit.h>
IB_DESIGNABLE
@interface LOLView : UIView
@property (nonatomic) IBInspectable UIColor *someColor;
@end
回答by Matt Gibson
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 的等效项。

