设置tableView头部view下拉放大

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);

}

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容