2016-03-10 123 views
0

我有一個基於視圖的NSTableView,背景顏色很深。 如果文本是白色的,Cocoa認爲文本框中的文本,彈出按鈕等可以更好地閱讀。在黑暗的背景中更改NSTableView中的文本編輯背景顏色

這本身是好的,我只有當我編輯文本字段中的文本時,編輯時的背景顏色是白色與白色文本的問題。

This is how it looks

是否有一個簡單的方法來得到這個權利(無論是黑暗的背景,而在編輯編輯或深色文本)或易我需要更動字段編輯器?

UPDATE

了一下週圍更擺弄之後,我發現,設置文本顏色上的所有單元格視圖文本字段爲黑色改變文字顏色爲黑色時,編輯。但是,它不會影響表格視圖中顯示的文字顏色。

我不確定這是否是一個錯誤,但它看起來像一個給我。

回答

1

你是否嘗試重寫didSelectRowAtIndexPath和didDeselectRowAtIndexPath來自己更新文本顏色?

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { 
    UITableViewCell *cell = (UITableViewCell *) [tableView cellForRowAtIndexPath:indexPath]; 
    if([cell isEditing]) { 
     cell.titleLabel.textColor = [UIColor blackColor]; 
    } 
} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = (UITableViewCell *) [tableView cellForRowAtIndexPath:indexPath]; 
    if([cell isEditing]) { 
     cell.titleLabel.textColor = [UIColor whiteColor]; 
    } 
} 

此代碼適用於iOS平臺,但應易於適應OSX平臺。

+0

這並沒有直接解決我的問題,但它指出了我的正確方向。謝謝! – guitarflow

+0

@guitarflow到底什麼是正確的方向? :) – ctietze