-
-
Save romanr/3003103 to your computer and use it in GitHub Desktop.
UITableViewCell subclass to handle indentationLevel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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