I have a custom UITableViewCell
and I would like to indent the UITextLabel
without indenting the separator's inset.
I tried the following but it didn't yield the result I was looking for. How can I achieve this? Can I edit the auto-layout the UITableViewCell uses? Or do I have to create my own UITextLabel
?
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
if (self) {
...
self.separatorInset = UIEdgeInsetsZero;
self.layoutMargins = UIEdgeInsetsZero;
...
self.textLabel.layoutMargins = UIEdgeInsetsMake(self.textLabel.layoutMargins.top,
self.textLabel.layoutMargins.left + 30,
self.textLabel.layoutMargins.bottom,
self.textLabel.layoutMargins.right);
}
return self;
}
Thanks!
For anyone looking for the solution to this.
You can override your the auto-layout constraints in the
initWithStyle:reuseIdentifier:
method like this: