补全cell分割线

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

        [cell setSeparatorInset:UIEdgeInsetsZero];

    }

    

    if ([cellrespondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]){

        [cell setPreservesSuperviewLayoutMargins:NO];

    }

    

    if ([cellrespondsToSelector:@selector(setLayoutMargins:)]){

        [cell setLayoutMargins:UIEdgeInsetsZero];

    }


需要注意的是preservesSuperviewLayoutMarginslayoutMargins是iOS8以后才有的,separatorInset是iOS7以后才有的,如果要兼容以前的版本记得先判断selector是否存在。

至于原因如下:

Setting the separatorInset of tableView to UIEdgeInsetsZero is not going to work. It will only effect the extra separators, not the cells that you created. 
iOS8 introduces layoutMargins property on UIView, along with another property called preservesSuperviewLayoutMargins indicating whether superview’s layoutMargins is preserved (Think of it as an override) which is YES by default. layoutMargins property is a set of insets from the edge of the view’s bounds that denote a default spacing for laying out content. 
The default separatorInset of tableView and tableViewCell is (top = 0, left = 15, bottom = 0, right = 0) 
The default layoutMargins of tableView and tableViewCell is (top = 8, left = 8, bottom = 8, right = 8) 
These 3 properties are defining the behaviour of separator indentation. 
However, setting tableView’s layoutMargins is not going to effect tableViewCell. Because tableViewCell’s superview is not tableView. It’s tableView’s subView, an instance of UITableViewWrapperView whose superClass is UIScrollView and whose layoutMargins is (top = 8, left = 15, bottom = 8, right = 15) and preservesSuperviewLayoutMargins is YES. 
You have to set separatorInset and layoutMargins of tableViewCell directly: 
tableViewCell.preservesSuperviewLayoutMargins = NO; 
tableViewCell.separatorInset = UIEdgeInsetsZero; 
tableViewCell.layoutMargins = UIEdgeInsetsZero; 
You can put those code in cell’s init method or awakeFromNib or tableView’s delegate tableView:willDisplayCell:fromRowAtIndexPath, etc.

大致的意思是说iOS7只有separatorInset的概念,在IOS7下tableView的分割线左边有15像素的间距。

iOS8中还有layoutMargins,用来表示子view和父view的间距,有8像素的间距。preservesSuperviewLayoutMargins默认为true表示开启子view与父view的间距。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在POI中设置单元格的边框线,可以使用CellStyle类的setBorderXxx()方法来实现,其中Xxx代表要设置的边框线类型。以下是一些常用的边框线类型及其对应的方法: 1. 设置左边框线: ```java CellStyle style = workbook.createCellStyle(); style.setBorderLeft(BorderStyle.THIN); ``` 2. 设置右边框线: ```java CellStyle style = workbook.createCellStyle(); style.setBorderRight(BorderStyle.THIN); ``` 3. 设置上边框线: ```java CellStyle style = workbook.createCellStyle(); style.setBorderTop(BorderStyle.THIN); ``` 4. 设置下边框线: ```java CellStyle style = workbook.createCellStyle(); style.setBorderBottom(BorderStyle.THIN); ``` 5. 设置所有边框线: ```java CellStyle style = workbook.createCellStyle(); style.setBorderLeft(BorderStyle.THIN); style.setBorderRight(BorderStyle.THIN); style.setBorderTop(BorderStyle.THIN); style.setBorderBottom(BorderStyle.THIN); ``` 请注意,上述代码中的`workbook`代表你创建的Workbook对象,可以根据你的实际情况进行相应调整。同时,上述代码只设置了细线边框,如果需要设置其他类型的边框线,可以使用`BorderStyle`枚举类中提供的不同常量。 最后,还需要将CellStyle应用到对应的单元格上,可以使用Cell类的setCellStyle()方法来实现。例如: ```java Cell cell = row.createCell(0); cell.setCellValue("Hello, World!"); cell.setCellStyle(style); ``` 这样就可以将单元格样式应用到指定的单元格上了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值