V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
fundon
V2EX  ›  iDev

在 macOS 和 Swift 3.0 中如何修改 NSTableRowView row 的 highlight 后的背景颜色

  •  
  •   fundon · 2016-08-08 18:15:16 +08:00 · 3032 次点击
    这是一个创建于 2810 天前的主题,其中的信息可能已经有所发展或是发生改变。
    尝试了 drawSelection , selectionHighlightStyle 都不能自定义用颜色
    8 条回复    2016-08-10 21:40:08 +08:00
    fundon
        1
    fundon  
    OP
       2016-08-08 20:45:51 +08:00
    自己解决了。
    xjbeta
        2
    xjbeta  
       2016-08-09 00:05:14 +08:00
    求分享代码 stack overflow 上找的 大多不怎么理想 和原来的蓝色相差挺大
    fundon
        3
    fundon  
    OP
       2016-08-10 11:48:52 +08:00
    fundon
        4
    fundon  
    OP
       2016-08-10 11:55:55 +08:00
    @xjbeta 记得把 rowView 的 selectionHighlightStyle 设置为 .none
    xjbeta
        5
    xjbeta  
       2016-08-10 15:55:52 +08:00
    @fundon 和 Alternating rows 一起用有点小问题 而且不支持多选 :P
    fundon
        6
    fundon  
    OP
       2016-08-10 18:04:24 +08:00
    @xjbeta 好,我现在的需求只要单选。找到解决方案分享下 :)
    xjbeta
        7
    xjbeta  
       2016-08-10 19:00:49 +08:00
    思路是 把 row 换成 selectedIndexs 然后用 foreach 遍历 修改每个 view 的颜色
    放在 tableViewSelectionIsChanging 里 这个通知有时候蜜汁不会调用
    放在 tableViewSelectionDidChange 里 又有点慢半拍的感觉
    fundon
        8
    fundon  
    OP
       2016-08-10 21:40:08 +08:00
    tableViewSelectionDidChange 肯定慢半拍
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1298 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 17:39 · PVG 01:39 · LAX 10:39 · JFK 13:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.