您的位置:首页 > 其它

图片放大功能

2015-08-25 15:03 363 查看
在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);
}
}


}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: