네비게이션 컨트롤러에 테이블 뷰가 있습니다. 표보기의 셀은 원본보다 너비가 작고 배경은 이미지입니다. "선택한 색상"을 어떻게 설정할 수 있습니까?UITableViewCell 너비
- (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;
}
괜찮 았지만 선택한 프레임이 더 작은 프레임이 아닙니다. – Filip
아니요, 전체 크기 인'selectedBackgroundView'를 설정 한 다음, 예제에서와 같이 적절한 크기를 가진 backgroundView에 하위 뷰를 추가해야합니다. 이것은 또한'backgroundView' 속성으로 무엇을 해야하는지입니다. –
아하 그것을 가지고 그것을 시도하고 알려 드리겠습니다! 당신의 도움을 많이 주셔서 고마워요 – Filip