-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ UIView* viewObj = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40];
UILabel *headerLabel = [[UILabel alloc] init];
headerLabel.font = [UIFont systemFontOfSize:14]; headerLabel.backgroundColor = [UIColor greenColor]; if(self.tableView.editing && section==0) { headerLabel.frame = CGRectMake(cellpositionX,0,self.tableView.bounds.size.width - cellpositionX,40); NSString *NewSection = @"My new header message in edit mode d\n\n OK"; headerLabel.text = NewSection; } else { headerLabel.frame = CGRectMake(0,0,self.tableView.bounds.size.width,40); headerLabel.text = [self tableView:tableView titleForHeaderInSection:section]; } [viewObj addSubview:headerLabel]; return viewObj;}
In the above code, you can pass the value of x to cellpositionX.
Also, every time a TableView starts and ends editing. you need to reload TableView
I hope this solves your problem.
source share