1.先設(shè)定頭部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代理里面實(shí)現(xiàn)這行代碼即可實(shí)現(xiàn)下拉放大
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat width = [UIScreen mainScreen].bounds.size.width;
CGFloat yOffset = scrollView.contentOffset.y? ;
//放圖片的view有多大? 這個的250這兩個位置也一樣改過來? 三個數(shù)字一樣
if (yOffset < 0) {
CGFloat totalOffset = 250 + ABS(yOffset);
CGFloat f = totalOffset / 250;
_imageView.frame = CGRectMake(- (width * f - width) / 2, yOffset, width * f, totalOffset);
}
}