【发布时间】:2015-05-30 10:57:48
【问题描述】:
我已经使用下面的代码设置了标题背景,但是当我单击添加为标题上的子视图的按钮时,我想在运行时再次将标题的颜色更改回来。 请给我代码,提前谢谢:)
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
header = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _tableView.bounds.size.width, 50)];
header.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"homeCellHeaderBackGround.png"]];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 30)];
label.text = _array[section][@"name"];
label.textColor = [UIColor whiteColor];
[header addSubview:label];
UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(230, 10, 70, 35)];
[button addTarget:self action:@selector(onExpandButton:) forControlEvents:UIControlEventTouchUpInside];
//[button setTitle:@"Expand" forState:UIControlStateNormal];
[button setTag:section];
[header addSubview:button];
return header;
}
【问题讨论】:
-
请查看此链接。可能你需要的就在这里。 [在此处输入链接描述][1] [1]:stackoverflow.com/questions/621389/…
标签: ios objective-c iphone uitableview