• 让UITableView 的 headerView跟随 cell一起滚动,tableHeaderView


    在进行UITableView开发的时候,我们有时希望在cell的上面放置一些按钮之类的空间,又想让这些空间跟着cell一起滚动,
    刚开始想着hederView,注意,这是tableView的section的hederView,代码如下
    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 160; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section; { UIView *view = [[UIView alloc] init]; view.backgroundColor = [UIColor whiteColor]; return view; } 后来发现这样不行,在网上搜到这篇文章
    http:
    //blog.csdn.net/tangaowen/article/details/64523,受这篇文章启发,
    原来UITableVIew有个属性tableHederView,于是可以这样设(注意这是UITableView的HederView)

    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    view.backgroundColor = [UIColor blackColor]; self.tableView.tableHeaderView = view;

    图中黑色是UITableView的HederView ,白色是tableView的section的hederView,这里只有一个section.

  • 相关阅读:
    c#数据类型
    遮罩层
    图片轮播
    js 获取浏览器高度和宽度值
    bootstrap、jquery
    洛谷P1442 铁球落地 题解
    HDU3016 Man Down 题解
    POJ2892 Tunnel Warfare 题解
    HDU2795 Billboard 题解
    CF920F SUM and REPLACE 题解
  • 原文地址:https://www.cnblogs.com/shanyimin/p/4358036.html
Copyright © 2020-2023  润新知