2

我似乎无法更改 UITableView 中 DetailTextLabel 的颜色。

我可以更改字体和大小,但不能更改颜色。这是我的代码:

public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{

  UITableViewCell cell = new UITableViewCell (UITableViewCellStyle.Value1, cellIdentifier); 

  cell.TextLabel.Text = Label;
  cell.TextLabel.AdjustsFontSizeToFitWidth = true;
  cell.UserInteractionEnabled = false;

  cell.DetailTextLabel.Font = UIFont.SystemFontOfSize (13f);
  cell.DetailTextLabel.Text = Data;
  cell.DetailTextLabel.AdjustsFontSizeToFitWidth = true;
  cell.DetailTextLabel.TextColor = new UIColor(0,0,0,0);  // THIS BIT NEVER WORKS
  // cell.DetailTextLabel.TextColor = UIColor.Black;  // NEITHER DID THIS.

} 

无论如何,DetailTextLabel 总是以灰色显示。我该如何改变这个?

4

3 回答 3

2
 cell.DetailTextLabel.textColor = [UIColor colorWithRed:0 green:0 blue:0.6 alpha:1]

试试这个我想这个工作

于 2012-12-24T06:33:43.293 回答
1

要更改默认 UITableViewCells 的颜色,包括设置单元格的背景颜色,请在下面添加委托方法:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
于 2013-03-25T08:21:20.727 回答
0

首先从类中制作自己的标签UILabel并设置所有要显示的属性,如字体颜色、字体大小。然后将此标签设置为cell.DetailTextLabel=yourLabel.

于 2012-12-24T12:23:06.520 回答