我有问题,细胞背景颜色总是变得清晰.我将uiview背景颜色设置为灰色,tableview背景颜色以清除颜色,我没有设置tableviewcell背景颜色来清除颜色.但细胞背景总是显示为灰色.任何人都可以对此有所了解.
谢谢

-(void)viewDidLoad
{
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"TableBackGround.png"]];
Acc_Details_TView.backgroundColor = [UIColor clearColor];
Acc_Details_TView.rowHeight = 40;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TransCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
switch ([Acc_Details_SegCtrl selectedSegmentIndex]) {
case 0:{
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"TableCell"] autorelease];
cell.backgroundColor =[UIColor clearColor];
cell.textLabel.font = [UIFont boldSystemFontOfSize:14];
cell.detailTextLabel.text = [[transcationsList objectAtIndex:([indexPath row])] valueForKey:@"Date"];
cell.detailTextLabel.font = [UIFont systemFontOfSize:12];
}
NSString *titleName =[[transcationsList objectAtIndex:([indexPath row])] valueForKey:@"Title"] ;
if ([titleName length] > 19) {
cell.textLabel.text = [titleName substringWithRange:NSMakeRange(0, 20)];
}
else{
cell.textLabel.text = titleName;
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
UILabel * acc_Amount = [[UILabel alloc] initWithFrame:CGRectMake(220, 5, 60,10)];
acc_Amount.textAlignment = UITextAlignmentRight;
acc_Amount.backgroundColor = [UIColor clearColor];
acc_Amount.text = [[transcationsList objectAtIndex:([indexPath row])] valueForKey:@"Amount"];
acc_Amount.font = [UIFont boldSystemFontOfSize:14];
[cell.contentView addSubview:acc_Amount];
UILabel * balance_Amount = [[UILabel alloc] initWithFrame:CGRectMake(220, 23, 60,10)];
balance_Amount.textAlignment = UITextAlignmentRight;
balance_Amount.text = @"$1234.50";
balance_Amount.backgroundColor = [UIColor clearColor];
balance_Amount.textColor = [UIColor grayColor];
balance_Amount.font = [UIFont systemFontOfSize:12];
[cell.contentView addSubview:balance_Amount];
return cell;
}
}
}
Run Code Online (Sandbox Code Playgroud)
尝试在方法中设置单元格的背景颜色
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
而不是你的cellForRowAtIndexPath:方法.
| 归档时间: |
|
| 查看次数: |
2203 次 |
| 最近记录: |