如何更改tableviewcell的backgroundimage?

时间:2010-10-29 01:10:32

标签: objective-c ios4

当我选择行时,更改背景图像?

2 个答案:

答案 0 :(得分:2)

        #define kCellHeight 50  //Replace '50' with Height of your UITableViewCell
        #define kSelectedCellBackgroundImage @"nameOfYourImage" //replace value inside "" with name of your image

        UIImageView *selectedBackgroundView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, kCellHeight)];
        [selectedBackgroundView setImage:[UIImage imageNamed:kSelectedCellBackgroundImage]];
        [cell setSelectedBackgroundView:selectedBackgroundView];
        [selectedBackgroundView release];

答案 1 :(得分:0)

selectedBackgroundView的{​​{1}}设置为自定义视图。