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


    条件一:  [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;

            

        }

        

        

    }

    厚积薄发
  • 相关阅读:
    【索引】SyntaxHighlighter 使用参考
    【索引】博客心得
    SyntaxHighlighter 使用参考(一) 概述
    PEGA 十合一吉他控制器连接电脑玩《吉他英雄3》
    从SourceForge上获取CVS管理的开源代码
    从SourceForge上获取SVN管理的开源代码
    整数哈希介绍
    回文时间
    D2js 是如何处理并发的
    Windows 安装JRuby 生成 war 到 tomcat 运行
  • 原文地址:https://www.cnblogs.com/yr434/p/4953651.html
Copyright © 2020-2023  润新知