UITableViewCell+RQExtension.m 888 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // UITableViewCell+RQExtension.m
  3. // XinShouJiaDao
  4. //
  5. // Created by 张嵘 on 2020/6/19.
  6. // Copyright © 2020 JCZ. All rights reserved.
  7. //
  8. #import "UITableViewCell+RQExtension.h"
  9. @implementation UITableViewCell (RQExtension)
  10. - (void)drawRect:(CGRect)rect {
  11. [super drawRect:rect];
  12. UITableView *superView = (UITableView *)self.superview;
  13. if (![superView isKindOfClass:[UITableView class]]) {
  14. superView = (UITableView *)self.superview.superview;
  15. }
  16. if ([superView isKindOfClass:[UITableView class]]) {
  17. NSIndexPath *indexPath = [superView indexPathForCell:self];
  18. NSInteger rows = [superView numberOfRowsInSection:indexPath.section];
  19. self.separatorInset = UIEdgeInsetsMake(0, 15, 0, 0);
  20. if(indexPath.row == rows -1) {
  21. self.separatorInset = UIEdgeInsetsMake(0, 0, 0, RQ_SCREEN_WIDTH);
  22. } else {
  23. self.separatorInset=UIEdgeInsetsMake(0, 15, 0, 0);
  24. }
  25. }
  26. }
  27. @end