Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Colors 选择时设置单元格背景颜色-Swift_Colors_Swift_Cell - Fatal编程技术网

Colors 选择时设置单元格背景颜色-Swift

Colors 选择时设置单元格背景颜色-Swift,colors,swift,cell,Colors,Swift,Cell,在stackOverflow上,我发现了一种方法,允许iOS用户更新tableCell的默认选定颜色。 现在,如何在OSX上使用Swift实现同样的功能 适用于iOS的代码: var bgColorView = UIView() bgColorView.backgroundColor = UIColor.redColor() cell.setSelectedBackgroundView = bgColorView 我试图为了OSX的目的更改代码。。无功而返 //Set selected col

在stackOverflow上,我发现了一种方法,允许iOS用户更新tableCell的默认选定颜色。 现在,如何在OSX上使用Swift实现同样的功能

适用于iOS的代码:

var bgColorView = UIView()
bgColorView.backgroundColor = UIColor.redColor()
cell.setSelectedBackgroundView = bgColorView
我试图为了OSX的目的更改代码。。无功而返

//Set selected color of cell
    var bgColorView = NSView()
    bgColorView.backgroundColor = NSColor.redColor()
    cell.setSelectedBackgroundView = bgColorView
这就是我得到的错误


谢谢大家。阿尔贝托。

var myBackView=UIViewframe:cell.frame

myBackView.backgroundColor=UIColor.redColor

cell.selectedBackgroundView=myBackView

试试这个:

cell.backgroundColor = UIColor.YellowColor()

这行在CellForRowatineXpath之后

请用错误的实际文本替换屏幕截图。对不起?我不明白。。错误在RedLite中出现。该网站主要基于文本。请删除屏幕截图并实际键入错误,以便它们实际可读并可以通过search.UIView找到?那不是OSX你看过问题了吗?如果我要求使用OSX,为什么要提到UI?NScell.backgroundColor=UIColor.yellowColor