设置图片下拉放大
这里是把这张图片作为tableView的头视图
static CGFloat ImageOriginHeight = 200;
_headerImageView = [FactoryUI createImageViewWithFrame:CGRectMake(0, -ImageOriginHeight, SCREEN_W, ImageOriginHeight) imageName:@"welcome1"];
[_tableView addSubview:_headerImageView];
//设置tableView 内容从ImageOriginHeight开始显示
_tableView.contentInset = UIEdgeInsetsMake(ImageOriginHeight, 0, 0, 0);
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
//实现下拉放大
//改变scrollview的偏移量来改变图片的frame值
if (scrollView == _tableView) {
//1。获取scrollview的偏移量
CGFloat yOffset = scrollView.contentOffset.y;
CGFloat xOffset = (yOffset + ImageOriginHeight) / 2;
if (yOffset < -ImageOriginHeight) {
CGRect resct = _headerImageView.frame;
//改变imageView的frame
resct.origin.y = yOffset;
resct.size.height = -yOffset;
resct.origin.x = xOffset;
resct.size.width = SCREEN_W + fabs(xOffset) * 2;
_headerImageView.frame = resct;
}
}
}