headView = [[UIView alloc] initWithFrame:CGRectMake(0, -98*SC, WID, 98*SC)]; //注意坐标!!
UIImageView *bannerImage = [[UIImageView alloc] initWithFrame:headView.bounds];
[bannerImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.tgj-care.com%@",_model.h_pic]] placeholderImage:[UIImage imageNamed:@"yuyue_banner"]];
bannerImage.contentMode = UIViewContentModeScaleAspectFill;
bannerImage.layer.masksToBounds = YES;
bannerImage.tag = 1;
[headView addSubview:bannerImage];
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WID, HEI - 64) style:UITableViewStylePlain];
_tableView.hidden = YES;
_tableView.rowHeight = 70;
_tableView.delegate = self;
_tableView.dataSource = self;
[_tableView addSubview:headView]; //这里不是设置表头,而是添加子视图到tableView上
_tableView.contentInset = UIEdgeInsetsMake(98*SC, 0, 0, 0); //注意内容坐标偏移
_tableView.tableFooterView = [[UIView alloc] init];
[self.view addSubview:_tableView];
#pragma mark - scrollView代理方法
//下拉顶部图片放大
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat y = scrollView.contentOffset.y;
if (y < -98*SC) { //下拉时调整坐标和高度
CGRect rect = headView.frame;
rect.origin.y = y;
rect.size.height = -y;
headView.frame = rect;
UIImageView *bannerImage = (id)[headView viewWithTag:1];
bannerImage.frame = headView.bounds;
}
}