新闻详情页顶部的下拉放大与上拉的层叠效果

条件一:  [self.view insertSubview:_imgView belowSubview:_tableView];

条件二:

   static NSString *cellId = @"cell1";

                cell = [tableView dequeueReusableCellWithIdentifier:cellId];

                if (!cell)

                {

                    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];

                    cell.selectionStyle = UITableViewCellSelectionStyleNone;

                   //不能重用,且底部要保持透明

                    cell.backgroundColor = [UIColor clearColor];

                    cell.contentView.backgroundColor = [UIColor clearColor];

                }

条件三  :- (void)scrollViewDidScroll:(UIScrollView *)scrollview {

    

    CGFloat offsetY = scrollview.contentOffset.y;

    

    if (offsetY > 0) {  //往上滑动改变图片的 y 值

        

        _imgView.top = -offsetY*0.5;

     

        

    } else {

        //向下滑动时放大图片且 y 值保持不变

        

        //原始宽度/原始高度 = 现在宽度/现在高度

        

        //现在的高度

        //ABS()取绝对值

        CGFloat height = SCREEN_WIDTH + ABS(offsetY);

        //现在宽度

        CGFloat width = SCREEN_WIDTH/(CGFloat)SCREEN_WIDTH * height;

        

        topImgFrm = _imgView.frame;

        

        topImgFrm = CGRectMake(-(width-SCREEN_WIDTH)/2.0, 0, width, height);

        

        _imgView.frame = topImgFrm;

        

    }

    

    

}