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;
        }
    }
    
  • 相关阅读:
    PHP AES256加密算法
    PHP字符串比较
    linux常用命令
    播放音乐方法(兼容IE FF Chrome Opera Safari)
    JS小游戏象棋暗棋
    Sublime Text 2 介紹
    php生成QRcode
    几种极其隐蔽的XSS注入的防护
    JS判断碰撞方法
    php 发送带附件邮件
  • 原文地址:https://www.cnblogs.com/zhendiao/p/5125904.html
Copyright © 2011-2022 走看看