美文网首页
NSTableview行选中时textcolor改变

NSTableview行选中时textcolor改变

作者: TessmileLu | 来源:发表于2016-12-06 13:01 被阅读0次

    在项目开发过程中,UI测试反馈一个Bug,TableView行选中时,行内字体图片发生改变。

    一开始认为是在行选中时,被自动设置成系统默认的选中字体颜色,便在行选中时,重新设置选中行里的文字字体颜色,并没有什么用。后来当tablecellview的backgroudstyle发生改变时,会影响其中的subview的backgroudstyle的改变。

    when the -backgroundStyle is NSBackgroundStyleDark, the view should use a light text color. Upon setting, the default implementation automatically forwards calls to all subviews that implement -setBackgroundStyle: or are an NSControl (which have NSCells that respond to -setBackgroundStyle:)

    于是我在继承的NSTableCellView类中重写- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle禁止subview的backgroundStyle改变。

    - (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle
    {
        [super setBackgroundStyle:backgroundStyle];
        if(backgroundStyle == NSBackgroundStyleDark)
        {
            self.textField.cell.backgroundStyle = NSBackgroundStyleLight;
            self.imageView.cell.backgroundStyle = NSBackgroundStyleLight; 
        }
    }
    

    j

    相关文章

      网友评论

          本文标题:NSTableview行选中时textcolor改变

          本文链接:https://www.haomeiwen.com/subject/otcrmttx.html