Change selection color on view-based NSTableView

前端 未结 13 2079
别跟我提以往
别跟我提以往 2020-12-07 19:11

Standard highlighting color in OS X applications is blue.

Is it possible to change it to another color, e.g. gray?

Note that I am using the new view-based

13条回答
  •  轮回少年
    2020-12-07 19:37

    You have to subclass NSTableView, and rewrite the functions below in order to change the alternating colors.

    • (void) drawRow: (NSInteger) row clipRect: (NSRect) clipRect

    • (void) drawBackgroundInClipRect: (NSRect) clipRect ** This one to change the main and alternate color **

    Use a for loop and insert this conditional (i % 2 == 0) to detect odd and even rows.

提交回复
热议问题