Skip to content

Instantly share code, notes, and snippets.

@brandons
Last active November 6, 2017 01:59
Show Gist options
  • Save brandons/c96f8aa9013c9c088150c7c436bfa452 to your computer and use it in GitHub Desktop.
Save brandons/c96f8aa9013c9c088150c7c436bfa452 to your computer and use it in GitHub Desktop.
//
// UITableView+HideSeparators.h
//
// Created by Brandon Schlenker on 11/5/17.
// Copyright © 2017 Brandon Schlenker. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UITableView (HideSeparators)
- (void)bs_hideSeparatorForRowAtIndexPath:(NSIndexPath *)indexPath;
@end
//
// UITableView+HideSeparators.m
//
// Created by Brandon Schlenker on 11/5/17.
// Copyright © 2017 Brandon Schlenker. All rights reserved.
//
#import "UITableView+HideSeparators.h"
#import <objc/runtime.h>
@implementation UITableView (HideSeparators)
+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
Method originalMethod = class_getInstanceMethod(class, NSSelectorFromString(@"_hideSeparatorForRowAtIndexPath:"));
Method swizzledMethod = class_getInstanceMethod(class, @selector(bs_hideSeparatorForRowAtIndexPath:));
method_exchangeImplementations(originalMethod, swizzledMethod);
});
}
- (void)bs_hideSeparatorForRowAtIndexPath:(NSIndexPath *)indexPath {
[self bs_hideSeparatorForRowAtIndexPath:indexPath];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment