ios - 框架中的 Swift @IBInspectable 属性未显示给 Interface Builder

标签 ios swift xcode6 interface-builder

我正在尝试使用 @IBInspectable 制作自定义 UIViewController 的框架,以在 Interface Builder 中编辑其属性。

public class BWWalkthroughPageViewController: UIViewController {
    @IBInspectable public var speed: CGPoint = CGPointZero
    @IBInspectable public var speedVariance: CGPoint = CGPointZero
    @IBInspectable public var animationType: String = ""
    @IBInspectable public var animateAlpha: Bool = false
}

如果框架源代码在示例应用程序项目中,属性将出现在属性检查器中,如下图所示,

IBInspectable

但是如果我将构建的框架添加到我的应用程序项目中,属性不会显示在检查器中。

是否可以向 Interface Builder 显示构建框架中的可检查属性?如果可以,怎么做?

这是框架源代码,它是从一个非框架项目派生出来的。 https://github.com/yoichitgy/BWWalkthrough/tree/support-carthage

最佳答案

创建框架

创建默认框架并在其中添加您的 swift 文件。

enter image description here

然后将您的 swift 文件设置为公开。

enter image description here

之后复制你的框架并将它添加到你的项目文件夹

enter image description here

使用框架

在你的项目中添加框架

enter image description here

在 Storyboard中创建新的 viewController 并设置位于框架中的 viewController 类

enter image description here

就是这样。您将在 Storyboard中看到您的属性。

关于ios - 框架中的 Swift @IBInspectable 属性未显示给 Interface Builder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28971624/

相关文章:

ios - 如何设置约束,以便 View 的宽度为 0(如果 View 不能至少达到某个宽度)

ios - 在 NSMutableArray Swift 中查找字符串

xcode6 - 在 Playground 上,如何关闭 Debug模式?

ios - itunes connect,上传后应用程序大小没有意义

ios - 内容未显示在 UITableView 中

ios - UITableViewCell 仅在滚动时更新为正确的高度

ios - Objective-C 字典参数不是 NSDictionary

ios - UILongPressGestureRecognizer 未调用其目标方法

ios - 突出显示和取消突出显示 UIView

ios - 设备上的图像尺寸错误