zoukankan      html  css  js  c++  java
  • iOS实现scrollView或者scrollView的子类下拉图片放大的效果

    代码是通过Tableview来说明的,用在其他情况下同样适用

    - (void)viewDidLoad {
        [super viewDidLoad];
        _imageview = [[UIImageView alloc]init];
        _imageview.image = [UIImage imageNamed:@"F2.jpg"];
        self.imageview.frame =CGRectMake(0, -150, self.tableView.frame.size.width, 150);
        //此处不能通过添加headerView的方式,因为添加headerview只能设置view的高
        [self.tableView addSubview:_imageview];
        self.tableView.contentInset = UIEdgeInsetsMake(150, 0, 0, 0);
        
    }
    
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        return 100;
    }
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        UITableViewCell * cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
        cell.textLabel.text = @"我是cell";
        return cell;
    }
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    
    -(void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
        //通过滑动的便宜距离重新给图片设置大小
        CGFloat yOffset = scrollView.contentOffset.y;
        if(yOffset<-150)
        {
            CGRect f= self.imageview.frame;
            f.origin.y= yOffset;
            f.size.height = -yOffset;
            self.imageview.frame = f;
        }
    }
    
  • 相关阅读:
    css3 动画+动画库
    垃圾回收 及 内存泄漏
    做菜体会
    微信小程序
    微信公众号2
    JavaScript 原生事件
    Bootstrap框架
    Less 和 Sass
    HTML标签总结
    表单元素
  • 原文地址:https://www.cnblogs.com/zhendiao/p/5125904.html
Copyright © 2011-2022 走看看