Skip to content

Instantly share code, notes, and snippets.

@liruqi liruqi/NSPZeroMarginCell.m
Last active Feb 23, 2016

Embed
What would you like to do?
Zero content margin UITableViewCell
// Hide separator for specific cell is extremely hard in iOS 9.
// None of these worked or good enough for me:
// http://stackoverflow.com/questions/8561774/hide-separator-line-on-one-uitableviewcell
@interface NSPZeroMarginCell : UITableViewCell
@property (nonatomic, assign) BOOL separatorHidden;
@end
@implementation NSPZeroMarginCell
- (void) layoutSubviews {
[super layoutSubviews];
CGRect f = self.textLabel.frame;
f.origin.x = 0;
self.textLabel.frame = f;
for (UIView *view in self.subviews) {
if (![view isKindOfClass:[UIControl class]]) {
if (CGRectGetHeight(view.frame) < 3) {
view.hidden = self.separatorHidden;
}
}
}
}
@end
@jrejaud

This comment has been minimized.

Copy link

commented Feb 23, 2016

Works great on iOS 9 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.