zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    var、let、const
    面向女朋友自我介绍
    ES6——class
    一个错误引发的——对异步回调与for循环(小白错误,大神勿进)
    关于this
    关于作用域
    HTML5 8
    HTML5 7
    HTML5 6
    HTML5 4
  • 原文地址:https://www.cnblogs.com/YuFly-lyx/p/8066475.html
Copyright © 2011-2022 走看看