第一步:添加一个顶部的View
// 设置tableView头部缩放view
_topView = [[UIView alloc]initWithFrame:ccr(0, 0, SCREEN_WIDTH, 0)];
_topView.backgroundColor = [UIColor colorWithHexString:@"c10000"];
[self.view addSubview:_topView];
第二步:检测scrollView 的滚动
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat offsetY = scrollView.contentOffset.y;
if (offsetY < 0) {
_topView.frame = CGRectMake(0, -offsetY, SCREEN_WIDTH , offsetY);
}
}