效果图:
其实实现比较简单,只要把要放大的ImageView的Y值和height根据拖动的Y值来改变就有这的效果了
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat offsetY = scrollView.contentOffset.y;
NSLog(@"%f",offsetY);
//多少距离开始放大
CGFloat zoomHeight = 100;
//设置下拉图片放大
if (offsetY < - zoomHeight) {
CGRect frame = self.headerView.backgroundView.frame;
NSLog(@"前frame:%@",NSStringFromCGRect(frame));
frame.origin.y = offsetY;
frame.size.height = - offsetY;
NSLog(@"后frame:%@",NSStringFromCGRect(frame));
self.headerView.backgroundView.frame = frame;
}
}