tags:

views:

25

answers:

1

Hi Developers,

I'm having one Table view. In that i want to set the color for the First cell alone..Others should be in white...How can i do that

I need your help....

Thanks in advance.....

+1  A: 

In cellForRowAtIndexPath, check if the indexPath.row == 0, then set the custom background. Otherwise set the default background.

// Customize the appearance of table view cells.
- (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...
    if (indexPath.row == 0) {
        //set custom background color
    } else {
        //set default background color
    }
    return cell;
}
mclin