创建一个UITableViewCell的扩展
在.m文件导入代码
#import "UITableViewCell+Expansion.h"
@implementationUITableViewCell (Expansion)
-(void)drawRect:(CGRect)rect
{
[superdrawRect:rect];
UITableView *superView = (UITableView *)self.superview;
if(![superViewisKindOfClass:[UITableViewclass]]) {
superView = (UITableView *)self.superview.superview;
}
if([superViewisKindOfClass:[UITableViewclass]]) {
NSIndexPath*indexPath = [superViewindexPathForCell:self];
NSIntegerrows = [superViewnumberOfRowsInSection:indexPath.section];
self.separatorInset=UIEdgeInsetsMake(0,15,0,0);
if(indexPath.row== rows -1) {
self.separatorInset=UIEdgeInsetsMake(0,0,0,kScreenWidth);
}else{
self.separatorInset=UIEdgeInsetsMake(0,15,0,0);
}
}
}
@end
网友评论