代码:
// 屏幕尺寸
#define ScreenH [UIScreen mainScreen].bounds.size.height
#define ScreenW [UIScreen mainScreen].bounds.size.width
//状态兰高度
#define StatusBarH [UIApplication sharedApplication].statusBarFrame.size.height
- (UITableView *)tableview {
if (!_tableview) {
_tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, ScreenH-TabbarHeight) style:UITableViewStylePlain];
_tableview.delegate = self;
_tableview.dataSource = self;
_tableview.showsVerticalScrollIndicator = NO;
_tableview.backgroundColor = Color(240, 244, 250);
_tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
if (@available(iOS 11.0, *)) {
self.tableview.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
UIView * stateView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, StatusBarH)];
stateView.backgroundColor = ThemeColor;
_tableview.tableHeaderView = stateView;
[self.tableview registerNib:[UINib nibWithNibName:@"ShopTopCell" bundle:nil] forCellReuseIdentifier:@"ShopTopCell"];
}
return _tableview;
}
//加载自定义XibCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ShopTopCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ShopTopCell" forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
效果图:
WechatIMG67.jpeg
WechatIMG68.jpeg
网友评论