Skip to content

Instantly share code, notes, and snippets.

@pier-oliviert
Created February 9, 2011 16:30
Show Gist options
  • Save pier-oliviert/818759 to your computer and use it in GitHub Desktop.
Save pier-oliviert/818759 to your computer and use it in GitHub Desktop.
UITableViewCell subclass to handle indentationLevel
- (void)layoutSubviews {
[super layoutSubviews];
float indentPoints = self.indentationLevel * self.indentationWidth;
if (indentPoints > 0) {
[self.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
UIView *view = (UIView *)obj;
CGFloat width = CGRectGetWidth(view.frame);
if (width > indentPoints * 2)
width -= indentPoints;
CGFloat x = CGRectGetMinX(view.frame);
if (x + indentPoints + width < CGRectGetMaxX(self.frame))
x += indentPoints;
view.frame = CGRectMake(
x,
CGRectGetMinY(view.frame),
width,
CGRectGetHeight(view.frame)
);
}];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment