图片下拉放大

传送门
//_bgImageView是要放大的图片,ImageWidth、ImageHeight分别是 _bgImageView原本的宽度和高度

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{

//滑动放大标签背景图片
[selfupdateImg];

}
//更新相册封面大小
- (void)updateImg {
 CGFloat yOffset   = self.tabelView.contentOffset.y;

 if (yOffset < 0) {
    
   CGFloat factor = ((ABS(yOffset) +ImageHeight) * ImageWidth) /ImageHeight;
   CGRect f = CGRectMake( - (factor -ImageWidth) / 2,0, factor, ImageHeight +ABS(yOffset));
   _bgImageView.frame = f;
    
}else {
    
   CGRect f = _bgImageView.frame;
    f.origin.y = - yOffset;
   _bgImageView.frame = f;
  
}
}

你可能感兴趣的:(图片下拉放大)