图片放大功能

来源:互联网 发布:eclipse java汉化教程 编辑:程序博客网 时间:2024/05/16 13:47

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

}

0 0
原创粉丝点击