我似乎无法在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始终显示为灰色。我该如何改变呢?
答案 0 :(得分:2)
cell.DetailTextLabel.textColor = [UIColor colorWithRed:0 green:0 blue:0.6 alpha:1]
尝试这个我想这个工作
答案 1 :(得分:1)
要更改默认UITableViewCells的颜色,包括设置单元格的背景颜色,请在下面添加委托方法:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
答案 2 :(得分:0)
首先从UILabel
类创建自己的标签,并设置要显示的所有属性,如字体颜色,字体大小。然后将此标签设置为cell.DetailTextLabel=yourLabel
。