html表格隐藏导航栏,ios 隐藏导航页面的tableView适配

这篇博客介绍了如何在iOS应用中设置UITableView的大小,使其适应屏幕尺寸,并且设置了状态栏的高度。同时,创建了一个自定义的XibCell,并在代码中注册了这个Cell。在iOS 11及以上版本中,处理了内容偏移量的适配问题,确保了视图布局的正确性。
摘要由CSDN通过智能技术生成

代码:

// 屏幕尺寸

#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;

}

效果图:

268eb9d240cd

WechatIMG67.jpeg

268eb9d240cd

WechatIMG68.jpeg

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值