尝试使用游乐场在Xcode中显示NSView,我是否还需要做其他任何事情才能显示视图?
使用Xcode 7.3 OSX 10.11.3
一些代码:
import Cocoa
import XCPlayground
class MyNSView: NSView {
override func drawRect(dirtyRect: NSRect) {
let blue = NSColor.blueColor()
blue.setFill()
//self.bounds
NSRectFill(self.bounds)
}
}
let vc = MyNSView(frame: NSRect(x: 0, y: 0, width: 200, height: 200))
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
XCPlaygroundPage.currentPage.liveView = vc