Code Bye

如何在cell里添加表头表尾巴,还有就是改变大小

 

如图我要设计成这样
设计表头表尾巴
而且大小要和中间的不一样 因为放的东西不同

可以详细代码贴一下吗?


25分
UITableView可以自定义表头表尾的
UIView *headV=[[UIView alloc] init];
…..设置你的headv

UIView *footV=[[UIView alloc] init];
….设置你的footv

self.tableview.headview=headV;
self.tableview.footView=footV;


25分
写错了,是tableFootView和tableHeadView

25分
tableHeaderView 和 tableFooterView 是很灵活的属性,宽度你不用指定,tableView 会帮你指定的,你只需要指定 height 就行了,类似于这样:
CGRect headerFrame = CGRectMake(0, 0, yourWidth, yourHeight);
UIView *headerView = [[UIView alloc] initWithFrame:headerFrame];
[headerView setBackgroundColor:[UIColor clearColor]];
YourCustomView *customView = [[YourCustomView alloc] initWithFrame: headerFrame];
[headerView addSubview:customView];
self.tableView.tableHeaderView = headerView;

tableFooterView 也类似。


25分
也可以用两个section.
1. 顶部的图片可以做为tableview的headerView来添加,它会随着tableview的滚动而滚动。如果要固定顶部的图片位置,那么就不能放到headerview中了。可以提到与tableview同级
2. tableview可以用两个section . 下方的简介为第二个section中的一个cell这个cell可以通过自定义cell实现。两个section之间的空的间距也可以通过设置heightForHeaderInSection: 
3. 显然下方的“我要报名”,“我要评论” 这两个按钮是固定在屏幕下方的,与tableview也在同一级上。

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明如何在cell里添加表头表尾巴,还有就是改变大小