表格分割線你們懂的,默認並非從最左側開始的iphone
在ipad中,發現,分割線距離最左和最右側,都有距離
ide
在iphone中,只有左側有空隙spa
去掉分割線:設置UITableView的separatorStyle = UITableViewCellSeparatorStyle.None3d
如今想讓分割線佔滿整個屏幕:orm
override func viewDidLoad() {ip
if tableView.respondsToSelector(Selector("setSeparatorInset:")) {it
tableView.separatorInset = UIEdgeInsetsZeroio
}event
if tableView.respondsToSelector(Selector("setLayoutMargins:")) {table
if #available(iOS 8.0, *) {
self.tableView.layoutMargins = UIEdgeInsetsZero
} else {
// Fallback on earlier versions
}
}
}
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
// Remove seperator inset
if cell.respondsToSelector("setSeparatorInset:") {
cell.separatorInset = UIEdgeInsetsZero
}
// Prevent the cell from inheriting the Table View's margin settings
if cell.respondsToSelector("setPreservesSuperviewLayoutMargins:") {
if #available(iOS 8.0, *) {
cell.preservesSuperviewLayoutMargins = false
} else {
// Fallback on earlier versions
}
}
// Explictly set your cell's layout margins
if cell.respondsToSelector("setLayoutMargins:") {
if #available(iOS 8.0, *) {
cell.layoutMargins = UIEdgeInsetsZero
} else {
// Fallback on earlier versions
}
}
}