zoukankan      html  css  js  c++  java
  • //头部拉伸效果

    //头部拉伸效果

    #import "ViewController.h"

    @interface ViewController ()<UITableViewDelegate,UITableViewDataSource>

    @property (nonatomic) UITableView *tabelView;

    @property (nonatomic, copy) NSArray *dataSource;

    @end

    @implementation ViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

        [self createUI];

    }

    -(void)createUI{

        

        self.dataSource = @[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"1",@"2",@"3",@"4",@"5",@"6",@"7"];

        

        self.tabelView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];

        self.tabelView.delegate = self;

        self.tabelView.dataSource = self;

        self.tabelView.contentInset = UIEdgeInsetsMake(200, 0, 0, 0);

        [self.view addSubview:self.tabelView];

        

        

        UIImageView *headerImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, -200, self.view.frame.size.width, 200)];

        headerImageView.image = [UIImage imageNamed:@"mineHeaderBackImage"];

        headerImageView.tag = 101;

    //    headerImageView.contentMode = UIViewContentModeScaleToFill;//上下填充

        headerImageView.contentMode = UIViewContentModeScaleAspectFill;//上下左右等比例填充

        [self.tabelView addSubview:headerImageView];

    }

    -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

        return 1;

    }

    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

        return self.dataSource.count;

    }

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"string"];

        if (cell==nil) {

            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"string"];

        }

        cell.textLabel.text = self.dataSource[indexPath.row];

        return cell;

    }

    -(void)scrollViewDidScroll:(UIScrollView *)scrollView{

        CGRect rect = [self.view viewWithTag:101].frame;

        CGPoint point = scrollView.contentOffset;

        if (point.y < -200) {

            //处于拉伸状态

            rect.origin.y = point.y;

            rect.size.height = -point.y;

            [self.view viewWithTag:101].frame = rect;

        }

        NSLog(@"point.y  %f",point.y);

    }

    - (void)didReceiveMemoryWarning {

        [super didReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

    }

    @end

  • 相关阅读:
    让层遮挡select(ie6下的问题)
    HTTP协议详解(真的很经典)
    网络编辑基础:对HTTP协议的头信息详解
    (OK) MIMP
    (OK) MIMP
    (OK) MIMP
    (OK)(OK) Android-x86-7.1.1/ kernel 4.4.62
    (OK)(OK) Android-x86-7.1.1/ kernel 4.4.62
    (OK) Android-x86-7.1.1/ kernel 4.4.62
    (OK)(OK) Android-x86-7.1.1/ kernel 4.4.62
  • 原文地址:https://www.cnblogs.com/lrr0618/p/5756031.html
Copyright © 2011-2022 走看看