将 UINavigationItem 设为 @IBDesignable
Make UINavigationItem as @IBDesignable
我想进行自定义 UINavigationItem
,可以进行更改并在情节提要中看到。我知道如何使用 @IBDesignable
和 @IBInspectable
自定义 UIView
,但我的问题是 UINavigationItem
没有 draw
方法,而 required init?(coder aDecoder: NSCoder)
是叫到很快。
解决这个问题的最佳方法是什么?
不幸的是,无法在界面生成器中呈现自定义 UINavigationItem
(@IBDesignable
的用途)。在 the docs(Live Rendering 部分)他们说你必须从 UIView
/NSView
继承 class。反过来,UINavigationItem
继承自NSObject
。
Live Rendering
You can use two different attributes—@IBDesignable and
@IBInspectable—to enable live, interactive custom view design in
Interface Builder. When you create a custom view that inherits from
the UIView class or the NSView class, you can add the @IBDesignable
attribute just before the class declaration. After you add the custom
view to Interface Builder (by setting the custom class of the view in
the inspector pane), Interface Builder renders your view in the
canvas.
我想进行自定义 UINavigationItem
,可以进行更改并在情节提要中看到。我知道如何使用 @IBDesignable
和 @IBInspectable
自定义 UIView
,但我的问题是 UINavigationItem
没有 draw
方法,而 required init?(coder aDecoder: NSCoder)
是叫到很快。
解决这个问题的最佳方法是什么?
不幸的是,无法在界面生成器中呈现自定义 UINavigationItem
(@IBDesignable
的用途)。在 the docs(Live Rendering 部分)他们说你必须从 UIView
/NSView
继承 class。反过来,UINavigationItem
继承自NSObject
。
Live Rendering
You can use two different attributes—@IBDesignable and @IBInspectable—to enable live, interactive custom view design in Interface Builder. When you create a custom view that inherits from the UIView class or the NSView class, you can add the @IBDesignable attribute just before the class declaration. After you add the custom view to Interface Builder (by setting the custom class of the view in the inspector pane), Interface Builder renders your view in the canvas.