Uitableview 如何使用Monotouch更改DetailTextLabel的颜色?
我似乎无法在UITableView中更改DetailTextLabel的颜色 我可以改变字体和大小,但不能改变颜色。这是我的密码:Uitableview 如何使用Monotouch更改DetailTextLabel的颜色?,uitableview,xamarin.ios,detailtextlabel,Uitableview,Xamarin.ios,Detailtextlabel,我似乎无法在UITableView中更改DetailTextLabel的颜色 我可以改变字体和大小,但不能改变颜色。这是我的密码: public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) { UITableViewCell cell = new UITableViewCell (UITableViewCellStyle.Value1
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始终以灰色显示。我如何改变这个
cell.DetailTextLabel.textColor = [UIColor colorWithRed:0 green:0 blue:0.6 alpha:1]
试试这个,我想这项工作首先要从
UILabel
类中创建自己的标签,并设置所有要显示的属性,如字体颜色、字体大小。然后将此标签设置为单元格。DetailTextLabel=yourLabel要更改默认UITableViewCells的颜色,包括设置单元格的背景色,请在下面添加委托方法:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
谢谢,但是不行。我在Monotouch中尝试了等效的方法,我认为是cell.DetailTextLabel.TextColor=newUIColor(0,0,0,0);这也没有效果<代码>单元格。detailTextLabel是只读属性;你不能设置它。