IBDesignable view not rendering

别来无恙 提交于 2019-12-10 23:37:34

问题


I have a simple @IBDesignable view that I have specified as the base class for the top level view in a scene in my macOS storyboard. For example:

@IBDesignable
class OvalView: NSView {
    override func draw(_ dirtyRect: NSRect) {
        super.draw(dirtyRect)

        NSColor.red.setFill()
        NSBezierPath(ovalIn: bounds).fill()
    }
}

When I run the app, this view appears fine. But this designable view is not rendered in my scene in Interface Builder:

Note, this problem only manifests itself when the view in question is the top level view of the scene. If I do it for subviews, it works fine:


回答1:


The issue is that Interface Builder does not appear to properly render a @IBDesignable macOS view in Interface Builder if that view is the top level view in a scene. It will in iOS, but not macOS. In macOS, it only renders the designable view in Interface Builder if it is a subview, but not the top level view.

I have filed a bug report. #27817119



来源:https://stackoverflow.com/questions/38906727/ibdesignable-view-not-rendering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!