3

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:

enter image description here

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:

enter image description here

Rob
  • 415,655
  • 72
  • 787
  • 1,044
  • This is an older post but as of XCode 10.2.1, this now works. – Jay Jun 09 '19 at 17:01
  • Weird. It's definitely working for me. Both the color and brush sizes change when I change those properties in IB's Inspector. – Jay Jun 09 '19 at 17:22
  • Unfortunately, I you misunderstood the question in this case, namely that the problem manifests itself only when dealing with the top-level view. The problem actually still persists in Xcode 10.2.1 and Xcode 11. – Rob Jun 09 '19 at 17:37
  • My apologies if I misunderstood 'top level view' - that could be taken in several different contexts. Does 'top level view' mean a NSViewControllers content view? e.g. on the storyboard, a window's viewControllers view? I am having a similar issue - just want to clarify. – Jay Jun 09 '19 at 18:00
  • See snapshots in the revised question. – Rob Jun 09 '19 at 18:50

1 Answers1

6

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

Rob
  • 415,655
  • 72
  • 787
  • 1,044