-(voID)tableVIEwSelectionDIDChange:(NSNotification *)notification{ NSInteger selectedRow = [_maintable selectedRow]; NStableCellVIEw *cell = [_maintable rowVIEwAtRow:selectedRow makeIfNecessary:NO]; cell.layer.backgroundcolor = [NScolor redcolor].CGcolor; NSLog(@"selected");}
但这不起作用.我发现Apple文档很混乱(也许我错了).我对Mac编程没有经验.
有人建议任何解决方案?基本上我需要选择颜色是透明的.
解决方法 首先设置tablevIEw选择高亮样式NStableVIEwSelectionHighlightStyleNone
然后在你的tablVIEw委托工具中
tableVIEw:shouldSelectRow:
并在其中编写此代码:
NStableVIEwRow *row= [_maintable rowVIEwAtRow:selectedRow makeIfNecessary:NO];row.backgroundcolor = [your color];return YES;
也阅读这些
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/NSTableViewDelegate_Protocol/index.html#//apple_ref/occ/intfm/NSTableViewDelegate/tableView:rowViewForRow:
选择风格
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTableView_Class/index.html#//apple_ref/occ/instp/NSTableView/selectionHighlightStyle
以上是内存溢出为你收集整理的objective-c – NSTableRowView / NSTableCellView如何将自定义颜色设置为选定的行?全部内容,希望文章能够帮你解决objective-c – NSTableRowView / NSTableCellView如何将自定义颜色设置为选定的行?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)