2

I seem to be unable to change the colour of the DetailTextLabel in a UITableView.

I can change the font and size but not the colour. Here is my code:

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.

} 

The DetailTextLabel always appears in grey no matter what. How do i change this?

Tanis Draven
  • 425
  • 1
  • 4
  • 14

3 Answers3

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

try this i suppose this work

Kasaname
  • 1,491
  • 11
  • 15
  • Thanks - but no it doesn't work. I tried the equivalent in Monotouch which I think is cell.DetailTextLabel.TextColor = new UIColor(0,0,0,0); This had no effect either! – Tanis Draven Dec 24 '12 at 12:06
1

To change the colors of the default UITableViewCells, including setting the background color of the cell, add the delegate method below:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
Mathew Waters
  • 486
  • 4
  • 6
0

First Make your own label from UILabel class and set all property which you want to show like font color, font size. Then set this label to cell.DetailTextLabel=yourLabel.

josh
  • 1,681
  • 4
  • 28
  • 61