我有一个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