1.先设定头部imageView的原始大小 并且让imageView添加到头部View,这时候头部View最好是tableView的heightView.
UIImageView *HeadImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, _headView.frame.size.width, _headView.frame.size.height)];//此处的高为250
HeadImageView.image = [UIImage imageNamed:@"img_bg"];
[_headView addSubview:HeadImageView];
在scView代理里面实现这行代码即可实现下拉放大
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat width = [UIScreen mainScreen].bounds.size.width;
CGFloat yOffset = scrollView.contentOffset.y ;
//放图片的view有多大 这个的250这两个位置也一样改过来 三个数字一样
if (yOffset < 0) {
CGFloat totalOffset = 250 + ABS(yOffset);
CGFloat f = totalOffset / 250;
_imageView.frame = CGRectMake(- (width * f - width) / 2, yOffset, width * f, totalOffset);
}
}