0
votes

Im adding 2 texts into a cell of a table. What I am doing is

UITableViewCell *cell =nil;

NSString *CellIdentifier = @"Cell";

cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];

[[UILabel alloc] initWithFrame:CGRectMake(80.0, 0.0, 220.0, 10.0)];

mainLabel.tag = 1003;

mainLabel.text = @"Text 1";

mainLabel.textAlignment = UITextAlignmentLeft;

mainLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin| UIViewAutoresizingFlexibleHeight; [cell.contentView addSubview:mainLabel];

}

I do the same thing to add secondLabel to a cell. What is displaying on the simulator is enter image description here

Now the problem is the background of 2 UILabel is not the same with the background of the cell ( my cells are grouped in the table view )

Does anyone know how to fix this problem.

Any comments are welcomed here Thanks

2

2 Answers

1
votes

If I have understand well the question, you need to delete the UILabel background because you want to show the UITableViewCell background instead. So I think you only have to do that:

 mainLabel.backgroundColor = [UIColor clearColor];
1
votes

Like the answer above, you should set the same color for both of the view.

cell.backgroundColor = [UIColor clearColor];

or you can set the color of the View you set.