TableView Cell Separator Line Not Extending Across the Entire Cell

北城以北 提交于 2020-01-03 11:47:07

问题


I am working on a new project and have used a storyboard for the UI. All of my tableViews have an issue with the line separator. The picture below shows two lines. The first is a blue one which was set in the attributes inspector. The second one is black and was added with an imageView that I placed in the cell. The line does extend to the right side of the cell but not the left. Any ideas?


回答1:


first set table view
1.set separatorInset of tableview instance to UIEdgeInsetsMake(0, 0, 0, 0)
second set cell
1.set preservesSuperviewLayoutMargins of cell (instance) to NO
2.set layoutMargins of cell to UIEdgeInsetsZero
3.saet separatorInset of cell to UIEdgeInsetsZero

Hope to help you




回答2:


You have to set your cell property called preservesSuperviewLayoutMargins to false

cell.preservesSuperviewLayoutMargins = false

Them you just have to set your cell layoutMargins to zero

cell.layoutMargins = UIEdgeInsetsZero

You need also to select you tableView separator,select custom and change left value from 15 to 0

You need to do the same for your cell, just change the left value value from 15 to 0:



来源:https://stackoverflow.com/questions/28655167/tableview-cell-separator-line-not-extending-across-the-entire-cell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!