如何从蓝色变为didSelectRow颜色橙色
试试这个代码: - 把代码给定的方法
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UIView *myBackView = [[UIView alloc] initWithFrame:cell.frame];
myBackView.backgroundColor = [UIColor colorWithRed:253.0/256.0 green:199.0/256.0 blue:235.0/256.0 alpha:1.0];// change the color to your orange color i used different color herer
cell.selectedBackgroundView = myBackView;
[myBackView release];
}
所接受的答案 – 2011-05-05 10:54:02
喜@Aman谢谢回答我 – pinku 2011-06-30 06:07:18
UIView *cellBgView = [[UIView alloc] initWithFrame:cell.frame];
cellBgView.backgroundColor = [UIColor orangeColor];
cell.selectedBackgroundView = cellBgView;
[cellBgView release];
谢谢回答我: – pinku 2011-06-30 06:06:51
首先,您需要设置backgroundView
的人说里面。第二,当选中单元格时,将调用-(void)setSelected:animated:
和-(void)setHighlighted:animated:
的UITableViewCell
。我想你的单元格是自定义的,从UITableViewCell
继承。
我喜欢重写-(void)setHighlighted:animated:
方法,并且在方法内部,我会做以下事情。
-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
[myLabel setHighlighted:highlighted];
[myIconImage setHighlighted:highlighted];
///.... propagate the highlighted event to subviews.
// Call super method.
[super setHighlighted:highlighted animated:animated];
}
接受一些答案,否则你是不会得到任何答案在未来... – visakh7 2011-05-05 11:16:25