码迷,mamicode.com
首页 > 其他好文 > 详细

TableView 常用小技巧

时间:2015-06-17 11:04:09      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

分割线顶格iOS8 UITableview分割线顶格的做法

//iOS8 Cell分割线顶格
if ([_tableView respondsToSelector:@selector(setSeparatorInset:)]) {
    [_tableView setSeparatorInset:UIEdgeInsetsZero];
}

if ([_tableView respondsToSelector:@selector(setLayoutMargins:)]) {
    [_tableView setLayoutMargins:UIEdgeInsetsZero];
}


//iOS8 Cell分割线顶格
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

清除多余cell分割线(cell很少时)

_tableView.tableFooterView=[[UIView alloc]init];//清除多余分割线

 

关闭UITableViewCell的被选中效果

cell.selectionStyle = UITableViewCellSelectionStyleNone;//无色

 取消选中状态

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];//取消选中状态
}

自定义UITableViewCell选中时背景
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellart.png"]];
//字体颜色
cell.textLabel.highlightedTextColor = [UIColor orangeColor];
[cell.textLabel setTextColor:orangeColor];//设置cell的字体的颜色

 

TableView 常用小技巧

标签:

原文地址:http://www.cnblogs.com/sixindev/p/4582585.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!