adding UIView into subView of cell, UITableViewController
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
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
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];
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.
链接地址: http://www.djcxy.com/p/60500.html上一篇: 计算字典对象中值的数量