在collectionView中铺了一个tableView, 在tableView的上面部分写一个headerView,在headerView上面铺了一个ImageView,把图片放在ImageView上; tableView向下滑动时,图片按比例放大,向上滑动时,原图比例向上滑动:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
DiErYeCollectionViewCell *cell = [[self.collectionView visibleCells] firstObject];
if (scrollView == cell.tabelView) {
if (scrollView.contentOffset.y <= 0) {
CGFloat newy = 300 - scrollView.contentOffset.y;
CGFloat newx = WIDTH * newy / 300;
cell.ImageView.frame = CGRectMake(-(newx - WIDTH) / 2, scrollView.contentOffset.y, newx, newy);
}else{
cell.ImageView.frame = CGRectMake(0, 0, WIDTH, 300);
}
}
}