- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
//往上滑动offset增加,往下滑动,yoffset减小
CGFloat yoffset = scrollView.contentOffset.y;
//处理背景图的放大效果和往上移动的效果
if (yoffset>0) {//往上滑动
_headImageView.frame = ({
CGRect frame = self.origialFrame;
frame.origin.y = self.origialFrame.origin.y - yoffset;
frame;
});
}else {//往下滑动,放大处理
_headImageView.frame = ({
CGRect frame = self.origialFrame;
frame.size.height = self.origialFrame.size.height - yoffset;
frame.size.width = frame.size.height*1.5;
frame.origin.x = _origialFrame.origin.x - (frame.size.width-_origialFrame.size.width)/2;
frame;
});
}
}
ps: _headImageView 为头部背景图片 origialFrame 的初始大小等于 _headImageView 的初始大小