学习网站
http://jingyan.baidu.com/album/fdffd1f85a3a4af3e98ca13c.html?picindex=1
主要代码
//变焦图片作为底层
@property(nonatomic,strong)UIImageView *spaceImgView;
//设置变焦图片的大小和位置
[_spaceImgView sd_setImageWithURL:[NSURL URLWithString:urlString]];
_spaceImgView.frame = CGRectMake(0, -imageHeight, kUIScreenWidth , imageHeight);
// _spaceImgView.userInteractionEnabled = YES;
//设置图片的高度和宽度都改变(必须设置,否则只有高度改变)
_spaceImgView.contentMode = UIViewContentModeScaleAspectFill;
//将图片加入集合视图上
[self.collectionView addSubview:_spaceImgView];
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
CGFloat y = scrollView.contentOffset.y;
if (y<-imageHeight) {
CGRect frame = _spaceImgView.frame;
frame.origin.y = y;
frame.size.height = -y;
_spaceImgView.frame = frame;
}
}