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

  • 相关阅读:
    委托
    队列和栈、泛型
    Java去除字符串中 除数字和逗号以外的符号
    SQL查询重复记录
    使用EasyExcel导出图片及异常处理
    Nacos开机自启
    Redis开机自启
    Nginx开机自启
    Java 向数组中添加元素
    Java:如何打印整个字符串数组?
  • 原文地址:https://www.cnblogs.com/YuFly-lyx/p/8066475.html
Copyright © 2011-2022 走看看