zoukankan      html  css  js  c++  java
  • 表格的下拉放大 ----------王朋

    表格下拉放大的效果是:

    创建TableView和ImageView,分别设置相关属性:

    _tableView=[[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
        _tableView.delegate=self;
        _tableView.dataSource=self;
        [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
        //设置TableView的contentInset属性
         _tableView.contentInset=UIEdgeInsetsMake(imageHeight, 0, 0, 0);
        [self.view addSubview:_tableView];
        _imageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, -imageHeight, self.view.frame.size.width,imageHeight )];
        _imageView.image=[UIImage imageNamed:@"icon.jpg"];
        //关键代码:UIViewContentModeScaleAspectFill,  contents scaled to fill with fixed aspect. some portion of content may be clipped.
        _imageView.contentMode=UIViewContentModeScaleAspectFill;
        
        [_tableView insertSubview:_imageView atIndex:0];

    然后再在代理方法中改变图片的Frame

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
        CGFloat h=scrollView.contentOffset.y;
        if (-h > imageHeight) {
            CGRect frame=_imageView.frame;
            frame.size.height=-h;
            frame.origin.y=h;
            _imageView.frame=frame;
        }
        
        NSLog(@"偏移量是%f",h);
    }
  • 相关阅读:
    《何以为家》--观影心得
    博弈论 -- 巴什博弈
    《黑客攻防技术-系统实战》第二章--栈溢出1
    《汇编语言》--程序范例
    《黑客攻防技术-系统实战》开篇讲解
    ptrace理解
    DPDK初始化
    C++ 对象内存模型
    DPDK学习路线计划
    DPDK学习开篇
  • 原文地址:https://www.cnblogs.com/sixindev/p/4554544.html
Copyright © 2011-2022 走看看