gpt4 book ai didi

swift - 如何使用 Swift playground 显示带有一些绘图的 NSView?

转载 作者:IT王子 更新时间:2023-10-29 05:30:04 25 4
gpt4 key购买 nike

基本上,我想在 NSView 的 Swift Playground 上测试图表绘制。

最佳答案

这是我现在使用的:

class CustomView: NSView {
init(frame: NSRect) {
super.init(frame: frame)
}
override func drawRect(dirtyRect: NSRect) {
color.setFill()
NSRectFill(self.bounds)
NSColor.yellowColor().setFill()
var r = NSMakeRect(0, y, self.bounds.width, 5)
NSRectFill(r)
}

var color = NSColor.greenColor()
var y: CGFloat = 0
}
var view = CustomView(frame:
NSRect(x: 0, y: 0, width: 300, height: 300))

view.color = NSColor.greenColor()
XCPShowView("chart", view)

for var i = 0; i < 100; ++i {
view.y = CGFloat(i) // <- try click on a plus sign opposite this line to add it to timeline
}

关于swift - 如何使用 Swift playground 显示带有一些绘图的 NSView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24045339/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com