2017-03-17 90 views
0

我試圖用下面的方法設置我自己的NSProgressIndicator。Swift:設置NSProgressIndicator的進度

class ProgressViewController : NSViewController 
{ 
    override func loadView() 
    { 
     let view = NSView(frame: NSMakeRect(0,0,300,120)) 
     view.wantsLayer = true 
     view.layer?.borderWidth = 0 
     self.view = view 

     let text = NSTextField(frame: NSRect(x: 20, y: 45, width: 260, height: 20)) 
     text.drawsBackground = true 
     text.isBordered = false 
     text.backgroundColor = NSColor.controlColor 
     text.isEditable = false 
     self.view.addSubview(text) 
     text.stringValue = "Progress Text" 

     let indicator = NSProgressIndicator(frame: NSRect(x: 20, y: 20, width: 260, height: 20)) 
     indicator.minValue = 0.0 
     indicator.maxValue = 100.0 
     indicator.doubleValue = 33.0 
     self.view.addSubview(indicator) 
    } 
} 

我的問題是指標總是顯示完整。我錯過了一招嗎?

回答

1

默認樣式不確定。將其設置爲false並且一切都應該正常:

indicator.isIndeterminate = false 
+0

謝謝。我知道這很容易。 – iphaaw

+0

我認爲新的OS X設計使其非常混亂。舊的「不確定」外觀更容易理解 –