iOS-UItableview 分割线(自定义+原生)方法总结
2016-02-23 14:22
686 查看
原生:
方法1:
方法二:
自定义方法3:
方法1:
_stationCodeTbaleView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
方法二:
#pragma mark - 分割线 -(void)viewDidLayoutSubviews { if ([_stationCodeInfoTbaleView respondsToSelector:@selector(setSeparatorInset:)]) { [_stationCodeInfoTbaleView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)]; } if ([_stationCodeInfoTbaleView respondsToSelector:@selector(setLayoutMargins:)]) { [_stationCodeInfoTbaleView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)]; } } -(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]; } }
自定义方法3:
-(void)customSeparateLineToCell:(UITableViewCell *)cell{ //自定义分割线 UIView *separateLineTop = [[UIView alloc] initWithFrame:CGRectMake(0, 0, cell.frame.size.width, 1)]; [separateLineTop setBackgroundColor:[UIColor grayColor]]; [cell.contentView addSubview:separateLineTop]; UIView *separateLineBottom = [[UIView alloc] initWithFrame:CGRectMake(0, cell.frame.size.height - 1, cell.frame.size.width, 1)]; [separateLineBottom setBackgroundColor:[UIColor grayColor]]; [cell.contentView addSubview:separateLineBottom]; }
相关文章推荐
- UI整理-----part7--模态视图 push&pop
- UI整理-----part6--页面间的传值
- Web UI 自动化测试环境搭建 (转载自51测试天地第三十九期上)
- 在keil mdk中的error: #28: expression must have a constant value
- 在非UI线程处理Bitmap
- 最简单的java GUI
- iOS开发第三方存储库YTKKeyValueStore
- 反编译jd_gui 去掉行号
- 安卓通知栏自定义布局提示(NotificationCompat.Builder)
- Easyui Datagrid 如何实现后台交互显示用户数据列表
- NSNumber和NSValue
- EasyUI datagrid 在ie8和360兼容模式兼容性问题
- 系统数据文件和信息 《APUE》 Chapter-6
- Qt使用教程之使用Qt Quick UI表单(三)
- 标准IO库 知识点百问《APUE》 chapter-5
- 标准IO库《APUE》 Chapter-5
- POJ 2442 Sequence 堆的思想的应用 STL 堆学习
- UINavigationBar
- Win32项目搭建Duilib界面个人体会总结
- new AlertDialog.Builder 提示错误