• ios_scrollView顶部图片下拉放大


    - (UIScrollView *)bgScrollView{
        if(!bgScrollView){
            bgScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.statusView.frame), CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)-20-49)];
            bgScrollView.delegate=self;
            bgScrollView.showsVerticalScrollIndicator=NO;
            bgScrollView.showsHorizontalScrollIndicator=NO;
            bgScrollView.backgroundColor = [UIColor hx_colorWithHexRGBAString:@"#f6f6f6"];
            bgScrollView.hidden=YES;
            bgScrollView.contentInset = UIEdgeInsetsMake(142*CGRectGetWidth(self.view.frame)/375, 0, 0, 0);
        }
        return bgScrollView;
    }
    
    - (UIImageView *)topImageView{
        if(!topImageView){
            topImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0,-(142*CGRectGetWidth(self.view.frame)/375), CGRectGetWidth(self.view.frame),142*CGRectGetWidth(self.view.frame)/375)];
            topImageView.backgroundColor = [UIColor hx_colorWithHexRGBAString:@"#ffffff"];
            topImageView.contentMode = UIViewContentModeScaleAspectFill;
            [topImageView sd_setImageWithURL:[NSURL URLWithString:@"www.baidu.com"] placeholderImage:[UIImage imageNamed:@"top_logo.png"] options:SDWebImageRetryFailed];
        }
        return topImageView;
    }
    
    
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
        CGPoint point = scrollView.contentOffset;
        if (point.y < -(142*CGRectGetWidth(self.view.frame)/375)) {
            CGRect rect = self.topImageView.frame;
            rect.origin.y = point.y;
            rect.size.height = -point.y;
            self.topImageView.frame = rect;
        }
    }
    

    1.设置scrollview图片偏移

    2.设置图片frame

    3.在滑动代理中修改图片frame

  • 相关阅读:
    用Intellij idea创建Maven项目JDK8源码阅读环境问题整理
    咱的Maven项目能用Junit5吗?
    43- 8 mvc知识点
    42-7 linq
    (Ant编程) Iqueryable 类型介绍
    Iqueryable 类型中 的 使用lambda 注意的坑。 (linq to sql)
    (Ant编程) Linq 的select 方法
    Scala模式匹配
    scala正则表达式
    P4336 [SHOI2016]黑暗前的幻想乡
  • 原文地址:https://www.cnblogs.com/YuFly-lyx/p/8066475.html
Copyright © 2020-2023  润新知