1下拉刷新
//=================下拉刷新
(void)downRefresh{
UIRefreshControl *refresh = [[UIRefreshControl alloc]init];
[tableView addSubview:refresh];
refresh.tintColor = [UIColor cyanColor];
refresh.tag = 1000;
refresh.attributedTitle = [[NSAttributedString alloc]initWithString:@”下拉刷新” attributes:@{NSForegroundColorAttributeName:[UIColor cyanColor]}];
[refresh addTarget:self action:@selector(refreshAct:) forControlEvents:UIControlEventValueChanged];
}(void)refreshAct:(UIRefreshControl*)refresh{
[refresh beginRefreshing]; //开始刷新
refresh.attributedTitle = [[NSAttributedString alloc]initWithString:@”正在刷新” attributes:@{NSForegroundColorAttributeName:[UIColor cyanColor]}];
[self performSelector:@selector(refreshFinish) withObject:nil afterDelay:5];
}(void)refreshFinish{
UIRefreshControl refresh = (UIRefreshControl )[tableView viewWithTag:1000];
refresh.attributedTitle = [[NSAttributedString alloc]initWithString:@”刷新失败” attributes:@{NSForegroundColorAttributeName:[UIColor cyanColor]}];
[refresh endRefreshing];//结束刷新
}
2选中单元格的处理
显示不一样的背景 字体
//=========选中cell 背景颜色变化 文字大小 颜色变化
- (void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UIView *view = [[UIView alloc]initWithFrame:cell.bounds];
view.backgroundColor = [UIColor redColor];
cell.selectedBackgroundView = view;
//新建一个label 得到原来label的text 但他遮不住 cell选中view 的文字 但可以将其设为通明 这样就看不出来了
UILabel *label = [[UILabel alloc]initWithFrame:cell.textLabel.bounds];
label.text = cell.textLabel.text;
label.textColor = [UIColor whiteColor];
label.font = [UIFont systemFontOfSize:24];
label.backgroundColor = [UIColor redColor];
[cell.selectedBackgroundView addSubview:label];
cell.textLabel.highlightedTextColor = [UIColor clearColor];
}
//=========选中cell 背景颜色变化 颜色变化 文字大小不能改变
(void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UIView *view = [[UIView alloc]initWithFrame:cell.bounds];
view.backgroundColor = [UIColor redColor];
cell.selectedBackgroundView = view;
cell.textLabel.highlightedTextColor = [UIColor whiteColor];
}