美文网首页
iOS:tableViewCell最右边显示箭头,字符,自定义分

iOS:tableViewCell最右边显示箭头,字符,自定义分

作者: iOS技术小卒 | 来源:发表于2017-10-25 16:51 被阅读1116次
箭头

1.添加iOS系统自带的cell的箭头

cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

2.去掉tableviewcell的间隔下划线

_tableView.separatorStyle=UITableViewCellSeparatorStyleNone;

3.添加自定义间隔线,加在下面的这个方法里面

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

//这里

}

如下:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

UIView*lbl = [[UIViewalloc]init];//定义一个label用于显示cell之间的分割线(未使用系统自带的分割线),也可以用view来画分割线

lbl.frame= CGRectMake(cell.frame.origin.x+10, cell.frame.size.height-5, cell.frame.size.width-20,1);

lbl.backgroundColor=  [UIColorlightGrayColor];

[cell.contentViewaddSubview:lbl];

}

相关文章

网友评论

      本文标题:iOS:tableViewCell最右边显示箭头,字符,自定义分

      本文链接:https://www.haomeiwen.com/subject/laaqpxtx.html