我有一個NSTextView,我用來顯示一個計時器。這個計時器每秒鐘更新到00:00。當計時器更新NSTextView的字符串時,NSTextView的行爲就好像它重繪,但使用其父視圖背景作爲自己的背景。NSTextView繼承父母更新的視圖背景
我的NSTextView有一個清晰的背景色,並且已被設置爲不繪製其背景。其父視圖爲其自己的背景繪製了3部分圖像。以下是NSTextView的代碼。
_timerLabel = [[NSTextView alloc] init];
[self.timerLabel setSelectable:NO];
[self.timerLabel setEditable:NO];
self.timerLabel.font = fontLoaded ? [NSFont fontWithName:@"DS-Digital" size:26.0f] : [NSFont fontWithName:@"Lucida Grande" size:26.0f];
self.timerLabel.textColor = [NSColor colorWithCalibratedRed:(50.0f/255.0f) green:(50.0f/255.0f) blue:(50.0f/255.0f) alpha:1.0f];
self.timerLabel.backgroundColor = [NSColor clearColor];
[self.timerLabel setDrawsBackground:NO];
[self.timerLabel setAllowsDocumentBackgroundColorChange:NO];
[self.timerLabel setAlignment:NSCenterTextAlignment];
self.timerLabel.string = @"5:11";
[self addSubview:self.timerLabel];
任何集成開發環境爲什麼會發生?我嘗試了所有我能想到的或在蘋果文檔中找到的東西,而且沒有任何東西能解決我的問題。任何幫助將不勝感激。
之前在NSTextView https://www.dropbox.com/s/za3twd8hb7r1apr/Screen%20Shot%202013-04-10%20at%205.37.10%20PM.png
更新文本在NSTextView https://www.dropbox.com/s/p0bsk63o8yweyqs/Screen%20Shot%202013-04-10%20at%205.37.28%20PM.png