私のアプリではUITableView
、私の1つにありますUIView
。すべてのセルの背景画像を追加しました。私の問題は、特定のセルを選択するときに、その特定のセルの背景画像だけを変更したいのですが、他のすべてのセルには古い背景画像が必要です。これどうやってするの。あなたのアイデアを共有してください。
これが私のcellForRowAtIndexPath
コードです
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
UIImageView *bgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"MenuItem3"]];
cell.backgroundView = bgView;
cell.textLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:14];
cell.textLabel.textColor = [UIColor whiteColor];
cell.textLabel.text = [arrayValue objectAtIndex:indexPath.row];
[cell setAccessoryType:UITableViewCellAccessoryNone];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}