我在导航控制器中放置了一个表格视图。表格视图的单元格宽度小于原始单元格,背景是图像。如何设置“选定的颜色”?到目前为止,这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ApplicationCell";
ApplicationCell *cell = (ApplicationCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[CompositeSubviewBasedApplicationCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
return cell;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
{
cellContentView = [[CompositeSubviewBasedApplicationCellContentView alloc] initWithFrame:CGRectInset(self.contentView.bounds, 0.0, 1.0) cell:self];
cellContentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
cellContentView.contentMode = UIViewContentModeRedraw;
//here i'm making the cells smaller in width than the rest of the tableView
CGRect framme = cellContentView.frame;
framme.size.width = framme.size.width-58;
//set the left space
framme.origin.x = framme.origin.x+29;
[cellContentView setFrame:framme];
[self.contentView addSubview:cellContentView];
}
return self;
}