Reputation: 3961
I have a Table View within my main UIViewController that has one non-editable prototype cell. I am trying to remove the left indent from the table view cell. No matter what method I use, the indent does not go away.
Here is what I have tried:
On the Table View: In Interface Builder > Attributes Inspector, I set Separator Inset to Custom with left inset of 0.
On the Table View Cell: In Interface Builder > Attributes Inspector, I set indentation Level and Width to 0. I also changed Separator to Custom with left 0.
I also tried the following in code:
myTable.layoutMargins = UIEdgeInsets.zero
myTable.separatorInset = UIEdgeInsets.zero
And this inside of cellForRowAt:indexPath
cell.indentationLevel = 0
cell.indentationWidth = 0
cell.layoutMargins = UIEdgeInsets.zero
return cell
Here's a screenshot of what's occurring:
I need all of the "Hello's" to left-align with the red section header text.
How can I remove the left-indent of the content?
Thanks.
Upvotes: 0
Views: 521
Reputation: 330
I'm sure that layoutMargins is the reason of indent on UITableViewCell. But I think you can't change layoutMargins. I almost don't use textLabel of UITableViewCell. You can refer to Setting layoutMargins of UIView doesn't work.
Upvotes: 1
Reputation: 1847
Have you tried using a custom cell with a label and at the required distance from the left edge?
Upvotes: 1
Reputation: 2444
Try this -
helloLabel.textAlignment = .Left
cell.addSubview(helloLabel)
Upvotes: 0