#import "ViewController.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)UIImageView *headView;
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
_headView = [[UIImageViewalloc]initWithFrame:CGRectMake(0, -200, [[UIScreenmainScreen]bounds].size.width,200)];
_headView.contentMode =UIViewContentModeScaleAspectFill;
_headView.image = [UIImageimageNamed:@"bbsenter0"];
[self.tableViewaddSubview:_headView];
}
-(UITableView*)tableView{
if (!_tableView) {
_tableView = [[UITableViewalloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)style:UITableViewStylePlain];
_tableView.contentInset =UIEdgeInsetsMake(200,0, 0, 0);
[self.viewaddSubview:self.tableView];
_tableView.delegate =self;
_tableView.dataSource =self;
}
return_tableView;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 10;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:@"cell"];
if (!cell) {
cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:@"cell"];
}
cell.textLabel.text =@"hello";
return cell;
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
CGFloat y = scrollView.contentOffset.y+64;//如果没有导航控制器,这里应该减去导航控制器的高度64
if (y< -200) {
CGRect frame = _headView.frame;
frame.origin.y = y;
frame.size.height = -y;
_headView.frame = frame;
}
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
}