直接復制到項目中即可使用
OC
-(void)viewDidLayoutSubviews{
[super viewDidLayoutSubviews];
if([tableView respondsToSelector:@selector(setSeparatorInset:)]){
[tableView setSeparatorInset:UIEdgeInsetsZero];
}
if([tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[tableView setLayoutMargins:UIEdgeInsetsZero];
}
}
-(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];
}
}
swift
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if tableView.respondsToSelector("setSeparatorInset:"){
tableView.separatorInset = UIEdgeInsetsZero
}
if tableView.respondsToSelector("setLayoutMargins:"){
if #available(iOS 8.0, *) {
tableView.layoutMargins = UIEdgeInsetsZero
} else {
// Fallback on earlier versions
}
}
}
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell,
forRowAtIndexPath indexPath: NSIndexPath) {
if tableView.respondsToSelector("setSeparatorInset:"){
tableView.separatorInset = UIEdgeInsetsZero
}
if tableView.respondsToSelector("setLayoutMargins:"){
if #available(iOS 8.0, *) {
tableView.layoutMargins = UIEdgeInsetsZero
} else {
// Fallback on earlier versions
}
}
}
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。