设置UITableViewCell分割线顶格
来源:互联网 发布:mysql.sock 作用 编辑:程序博客网 时间:2024/06/06 02:11
设置UITableViewCell分割线顶格
转载# http://www.jianshu.com/p/afa312d046e3
iOS 7下
想要设置cell的分割线缩进为0,在iOS7中只用简单的设置 cell.separatorInset = UIEdgeInsetZero;
iOS 8下
在iOS8下,上面的方法就不行啦,经过查阅资料, 终于在stackoverflow上查到了详细的说明,源地址戳这里stackoverflow;
This property isn't available on iOS 7.0 so you need to make sure you check before assigning it!
Additionally, Apple has added a property to your cell that will prevent it from inheriting your Table View's margin settings. When this property is set, your cells are allowed to configure their own margins independently of the table view. Think of it as an override.
This property is called preservesSuperviewLayoutMargins, and setting it toNO will allow the cell's layoutMargin setting to override whatever layoutMargin is set on your TableView. It both saves time (you don't have to modify the Table View's settings), and is more concise. Please refer to Mike Abdullah's answer for a detailed explanation.
iOS8中,新加入了一个属性:preservesSuperviewLayoutMargins,呐,这个属性的加入,可以避免你的cell的外边继承自你的tableView,当你设置这个属性的时候,你可以自由的设置你的cell的外边距,而不必担心tableView和cell两者的相互影响.(翻译的好渣,你们自己去看英文吧...)
具体怎么代码实现呢
//Setup your cell margins:-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { // Remove seperator inset if ([cell respondsToSelector:@selector(setSeparatorInset:)]) { [cell setSeparatorInset:UIEdgeInsetsZero]; } // Prevent the cell from inheriting the Table View's margin settings if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) { [cell setPreservesSuperviewLayoutMargins:NO]; } // Explictly set your cell's layout margins if ([cell respondsToSelector:@selector(setLayoutMargins:)]) { [cell setLayoutMargins:UIEdgeInsetsZero]; }}
- 设置UITableViewCell分割线顶格
- UITableViewCell 分割线顶格
- UITableViewCell分割线左边顶格
- iOS开发中设置UITableViewCell中的分割线顶格显示
- uitableViewCell分割线满格 顶格
- 设置cell分割线顶格
- iOS 之 UITableViewCell 分割线左边没有顶格 解决方法
- UITableViewCell分割线设置满屏
- UITableViewCell自定义分割线
- UITableViewCell自定义分割线
- UITableViewCell 分割线顶头
- UITableViewCell的分割线
- 设置UITableviewCell的separatorStyle左边顶格
- UITableViewCell分割线从最左边开始和分割线颜色设置
- iOS -- UITableViewCell的分割线
- uitableviewcell去掉多余分割线
- UITableViewCell 分割线左对齐
- UITableViewCell分割线顶边
- codeforces 629C Famil Door and Brackets(dp)
- 字符串匹配的Boyer-Moore算法
- iOS 开发 -- Swift (十一) 便利构造函数
- win10 下如何安装 使用vc6.0
- 用链表实现一元多项式的加法运算
- 设置UITableViewCell分割线顶格
- iOS 点/长按地图放/ 移除大头针并显示地址
- Linux文件系统的目录结构
- JavaScript Core -- 函数表达式面试题
- Java网络编程
- 创建Model三部曲
- MyEclipse10 Servers窗口出现“Could not create the view: An unexpected exception was thrown”解决办法
- CodeForces 612 A. The Text Splitting(水~)
- Node.JS 利用socket.io 实现dj播放及聊天程序 代码