一、关于分割线的位置。

分割线的位置就是指分割线相对于tableViewCell.如果我们要根据要求调节其位置,那么在iOS7.0版本以后,提供了一个方法如下:

if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {

[self.tableView setSeparatorInset:UIEdgeInsetsMake(0, 45, 0, 0)];

}//上、左、下、右的距离,都是CGFloat型

//设置分割线为白色

[self.tbView setSeparatorColor:[UIColor redColor]];

//UITableViewCell的分隔线格式

[self.tbView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];

//设置组与组之间间距  不能用- (  float )tableView:( UITableView *)tableView heightForFooterInSection:(  NSInteger )section

self.tableView.sectionFooterHeight = 1.0;

//ios8以后通过这个方法设置组间距  不能用self.tableView . sectionHeaderHeight  = 8.0

- (  CGFloat )tableView:(  UITableView *)tableView heightForHeaderInSection:( NSInteger )section

{

return 8.0 ;

}

由于tableView是继承于scrollView,所以tableview的分割线会产生偏移,可以采用下面的方法进行设置,从而使分割线可以充满整个tableView

iOS8以后的新方法:复制即可

//系统分割线定格设置

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {

[tableView setLayoutMargins:UIEdgeInsetsZero];

}

if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {

[cell setLayoutMargins:UIEdgeInsetsZero];

}

if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {

[cell setSeparatorInset:UIEdgeInsetsZero];

}

}

tableViewCell 分割线自定义:首先要把cell自带的分割线给去掉,使用如下两种都行,一是把颜色设置为clearColor,二是风格设置为UITableViewCellSeparatorStyleNone。

自定义cell分割线

a、把自定义的分割线当成一个View放到cell的contentView上,一定要注意重用问题,所以这个view 要在cell初始化的时候添加上。示例代码如下:

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

{

UITableViewCell *cell = nil;

cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];

if (cell == nil) {

cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];

cell.accessoryView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"huicellacce"]];

cell.backgroundColor = [UIColor clearColor];

//        cell.selected = YES;

UIImageView *imageViewSepE = [[UIImageView alloc]initWithFrame:CGRectMake(47, 49, 200, 1)];

imageViewSepE.image = [UIImage imageNamed:@"godline"];

[cell.contentView addSubview:imageViewSepE];

}

}

联动

NSIndexPath *moveToIndexPath = [NSIndexPath indexPathForRow:0 inSection:indexPath.row];

// 将右侧 tableView 移动到指定位置

[self.tableView selectRowAtIndexPath:moveToIndexPath animated:YES scrollPosition:UITableViewScrollPositionTop];

// 取消选中效果

[self.tableView deselectRowAtIndexPath:moveToIndexPath animated:YES];

//滑动条在左侧

tableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, tableView.bounds.size.width-7);

iOS tableView的系统分割线定格设置以及分割线自定制的更多相关文章

  1. iOS tableView分割线高度自定义

    1.系统自带的集中分割线的形式 myTableView.separatorStyle=UITableViewCellSeparatorStyleNone;(这个是去掉所有分割线)可以通过这个来设置 2 ...

  2. iOS tableView移除某一行的分割线 让分割线宽度为整个cell的宽度

    移除tableViewCell中某一行的分割线 有2种方法 1. 移除系统的分割线,自己定义每行的分割线 self.tableView.separatorStyle = UITableViewCell ...

  3. ios系统中各种设置项的url链接

    ios系统中各种设置项的url链接 在代码中调用如下代码:NSURL*url=[NSURL URLWithString:@"prefs:root=WIFI"];[[UIApplic ...

  4. iOS - 跳到系统App内部设置

    从App中跳转到手机设置中此App内的设置授权界面: NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; if ...

  5. iOS tableview的常用delegate和dataSource执行顺序

    在这次项目中遇到了一个特别奇葩的问题:表视图创建的cell在7以上的系统能正常运行显示,在模拟器上就不能正常实现......为解决这个问题,纠结了好久...... 对在7系统上不显示的猜测: 用mas ...

  6. iOS开发UI篇—ios应用数据存储方式(偏好设置)

    iOS开发UI篇—ios应用数据存储方式(偏好设置) 一.简单介绍 很多iOS应用都支持偏好设置,比如保存用户名.密码.字体大小等设置,iOS提供了一套标准的解决方案来为应用加入偏好设置功能 每个应用 ...

  7. IOS tableView的一些问题总结

      1.与用户的交互的开启和关闭 tableView.userInteractionEnabled = NO; 2.TableView的Group样式中,默认的每个section都有sectionHe ...

  8. linux 系统文件类型、系统安装时间、系统启动时间、系统运行时间、设置及显示时间、系统时间和硬件时间

    系统文件类型: 1) $mout 2) df -l:仅列出本地文件系统:-h (--human-readable):-T:文件系统类型 $df -lhf 3) file -s (--special-f ...

  9. iOS TableView多级列表

    代码地址如下:http://www.demodashi.com/demo/15006.html 效果预览 ### 一.需求 TableView多级列表:分级展开或合并,逐级获取并展示其子级数据,可以设 ...

随机推荐

  1. Aa3.0 事件机制

    说明:本文由多处网络文章整理而成,在此未一一注明原文链接,敬请谅解! AS3:事件流机制  事件流 只要发生事件,Flash Player就会调度该事件对象. 如果事件目标不在显示列表中,则Flash ...

  2. List<T>集合导出csv方法参考,通过增加自定义的属性控制输出的字段。

    public string CreateAdvExcel(List<GridScoreManager> lt) { StringBuilder builder = new StringBu ...

  3. Linux Samba服务主配文件smb.conf中文详解

    从网上找到描述比较详细的smb.conf中文解释: 服务名:smb 配置目录:/etc/sabma/ 主配置文件:/etc/sabma/smb.conf #====================== ...

  4. BT 的相关资料

    1.Android中bluetooth的架构 http://blog.csdn.net/u011960402/article/details/11035947 2.Android4.0中Bluetoo ...

  5. php 分析

    php  code in D:\10\11\php test in D:\10\11\php\test issue 1: <html><head><title>标记 ...

  6. linux 目录及文件的命名规则、ls操作

    linux 命名: 1 不超过255个字符 2 严格区分大小写 3 除/外,其他的字符都是合法的 注意:1)避免文件名首字符使用+ - .(避免和隐藏文件混淆) 2)避免文件名使用空格,制表符以及@# ...

  7. GO interface显示类型转换方法

    一共两种,直接看代码 import ( "fmt") func main() { //var i interface{} = "TT" var i interf ...

  8. 关于reportng生成的测试报告不按测试执行顺序的解决办法

    需要修改TestResultComparator类的源码,源码自己去reportng官网http://reportng.uncommons.org/下载,因为reportng默认是按字母先后顺序进行排 ...

  9. Android:关于背景选择器Selector的item顺序

    在使用背景选择器的时候,如果item的顺序不对,会导致不起作用. 1.首先背景选择器的normal选项一定要放在最后. 2.pressed的选择器应该在seclet的前面.我在使用的时候找了半天问题, ...

  10. Windows下Discuz搭建论坛过程

    搭建环境:Win7 + XAMPP5.5 + Discuz3.2 GBK 官方论坛下载安装包,解压,把upload文件夹拷贝到网站文档根目录(例如我的为:D:\IT\XAMPP5.5\htdocs\) ...