美文网首页
ios 隐藏导航页面的tableView适配

ios 隐藏导航页面的tableView适配

作者: 缘來諟夢 | 来源:发表于2020-11-24 10:57 被阅读0次

代码:

// 屏幕尺寸
#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

相关文章

网友评论

      本文标题:ios 隐藏导航页面的tableView适配

      本文链接:https://www.haomeiwen.com/subject/lbkiiktx.html