当单元格中有复选标记时,将标签设为蓝色

时间:2011-10-26 01:55:56

标签: ios cocoa-touch

我知道如何将复选标记作为acessoryView的{​​{1}}。与“设置”应用不同,当UITableViewCell旁边有复选标记时,我的textLabel不会变为蓝色。是否有一个简单的样式属性我必须为此设置,或者我被迫手动更改textColor上的textLabel属性?如果后者是真的,这个特殊的蓝色阴影是否存储在某个地方?

enter image description here

1 个答案:

答案 0 :(得分:5)

iOS 3.0中已弃用

selectedTextColor,因此我认为您必须使用highlightedTextColor的{​​{1}}属性的UITableViewCell属性。我相信textLabel是用于突出显示文本的正确的默认蓝色阴影:

[UIColor colorWithRed:50.0/255.0 green:79.0/255.0 blue:132.0/255.0 alpha:1.0]

UITableViewCell Documentation


你可能也想要一个不同的单元格样式然后默认。 cell.textLabel.highlightedTextColor = [UIColor colorWithRed:50.0/255.0 green:79.0/255.0 blue:132.0/255.0 alpha:1.0]; // cell.textLabel.highlightedTextColor = [UIColor colorWithRed:0.196 green:0.3098 blue:0.52 alpha:1.0]; 是设置应用使用的内容:

  

细胞样式

UITableViewCellStyleValue1
     

带有文本标签(黑色和左对齐)和可选图像视图的单元格的简单样式。注意   这是iOS 3.0之前的单元格的默认样式。

     typedef enum {
         UITableViewCellStyleDefault,
         UITableViewCellStyleValue1,
         UITableViewCellStyleValue2,
         UITableViewCellStyleSubtitle
     } UITableViewCellStyle; 

     UITableViewCellStyleDefault
     

单元格样式,单元格左侧带有标签,左对齐和黑色文本;在右侧是一个标签,蓝色文字较小,右对齐。   “设置”应用程序使用此样式的单元格。

     UITableViewCellStyleValue1
     

单元格左侧的标签单元格样式,文本右对齐,蓝色;上   单元格的右侧是另一个文本较小的标签   左对齐和黑色。电话/联系人应用程序使用单元格   这种风格。

     UITableViewCellStyleValue2 
     

单元格的样式,顶部有一个左对齐的标签,下面有一个左对齐的标签   较小的灰色文字。 iPod应用程序使用这种风格的单元格。


获得this SO question (text-color-to-match-default...)

的颜色