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

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

作者: King_mr | 来源:发表于2017-10-28 15:29 被阅读0次

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

    话不多说直接上图

    看图.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

    好了 就这样

    相关文章

      网友评论

          本文标题:仿饿了么首页滑动效果[2]

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