Skip to content

Instantly share code, notes, and snippets.

@liruqi
Last active February 23, 2016 21:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liruqi/9a5add4669e8d9cd3ee9 to your computer and use it in GitHub Desktop.
Save liruqi/9a5add4669e8d9cd3ee9 to your computer and use it in GitHub Desktop.
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
Copy link

jrejaud 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