- (void)viewDidLoad {
[super viewDidLoad];
_imageview = [[UIImageView alloc]init];
_imageview.image = [UIImage imageNamed:@"F2.jpg"];
self.imageview.frame =CGRectMake(0, -150, self.tableView.frame.size.width, 150);
//此處不能通過添加headerView的方式冯丙,因為添加headerview只能設置view的高
[self.tableView addSubview:_imageview];
self.tableView.contentInset = UIEdgeInsetsMake(150, 0, 0, 0);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 100;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell * cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
cell.textLabel.text = @"我是cell";
return cell;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
//通過滑動的便宜距離重新給圖片設置大小
CGFloat yOffset = scrollView.contentOffset.y;
if(yOffset<-150)
{
CGRect f= self.imageview.frame;
f.origin.y= yOffset;
f.size.height = -yOffset;
self.imageview.frame = f;
}
}