仿饿了么首页滑动效果[2]

咳咳,上午刚发表的,中午就被大牛教做人了....

话不多说直接上图

看图.jpg

经过大牛指点,原来...原来就这么简单....好忧伤啊,感觉活着好累啊...

好了 不 bb 了 上代码

_tableView = [[UITableView alloc]init];
    _tableView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    _tableView.delegate = self;
    _tableView.dataSource = self;
    // 隐藏滑动条
    _tableView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:_tableView];
    UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)];
    header.backgroundColor = [UIColor orangeColor];
    // 设置header
    _tableView.tableHeaderView = header;

然后实现协议方法就哦了

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (SCREEN_HEIGHT == 812)
    {
        return 108;
    }
    else
    {
        return 64;
    }
}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    _navigationView = [[UIView alloc]init];//创建一个视图
    _navigationView.backgroundColor = [UIColor redColor];
    
    return _navigationView;
}


// MARK: -- UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    return 30;
}
3.gif

好了 就这样

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容