Last active
February 23, 2016 21:55
-
-
Save liruqi/9a5add4669e8d9cd3ee9 to your computer and use it in GitHub Desktop.
Zero content margin UITableViewCell
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
// 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works great on iOS 9 :)