框架中的Swift @IBInspectable属性未显示到Interface Builder

Yoi*_*aya 11 interface-builder ios swift xcode6

我正在尝试使用@IBInspectable在Interface Builder中编辑其属性来创建自定义UIViewController的框架.

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
}
Run Code Online (Sandbox Code Playgroud)

如果框架源代码位于示例应用程序项目中,则属性将出现在Attribute Inspector中,如下图所示,

IBInspectable

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

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

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

bar*_*dog -1

这些属性不会显示在应用程序的 Interface Builder 中但会显示在框架中的原因是,您的框架不是应用程序的目标。确保包含它的最简单方法是使用Cocoapods,它会为您很好地处理所有事情,并且设置相对简单。

旁注:彼此之间IBDesignable确实IBInspectable没有任何关系。使用IBInspectable,您可以向 Interface Builder 或 Storyboard 公开有限数量的属性类型(例如NSNumberBoolUIColor等)。IBDesignable然而用于在笔尖或故事板中实时渲染您的视图。它们一起使用非常方便,即更改可检查属性的属性并查看渲染的视图。