1.导入第三方库
pod 'DZNEmptyDataSet'
2.使用
#import <DZNEmptyDataSet/UIScrollView+EmptyDataSet.h>
DZNEmptyDataSetSource, DZNEmptyDataSetDelegate
//空数据空白 self.tableView.emptyDataSetSource = self; self.tableView.emptyDataSetDelegate = self;
#pragma mark -- DZNEmptyDataSetSource - (NSAttributedString *)descriptionForEmptyDataSet:(UIScrollView *)scrollView { NSString *text = @"暂无未读消息"; NSMutableParagraphStyle *paragraph = [NSMutableParagraphStyle new]; paragraph.lineBreakMode = NSLineBreakByWordWrapping; paragraph.alignment = NSTextAlignmentCenter; NSDictionary *attributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:UIColorFromRGB(0xB8B8B8), NSParagraphStyleAttributeName:paragraph }; return [[NSAttributedString alloc] initWithString:text attributes:attributes]; } - (CGFloat)spaceHeightForEmptyDataSet:(UIScrollView *)scrollView { return 25.0f; } //往上偏移64高度 - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView { return -64; }