zoukankan      html  css  js  c++  java
  • iOS界面动画特效

    1、TableView的headView背景图片拉伸

    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        
        _bgImage =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, CScreenWidth, CScreenHeight)];
        _bgImage.image = [UIImage imageNamed:@"pic4"];
        orginYframe = _bgImage.frame;
        [self.view addSubview:_bgImage];
        
        _headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CScreenWidth, 64)];
        _headView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0];
        _titleLBel = [[UILabel alloc] init];
        _titleLBel.frame =CGRectMake(0, 20, CScreenWidth, 44);
        _titleLBel.text = @"测试界面";
        _titleLBel.textColor = [UIColor greenColor];
        _titleLBel.textAlignment = NSTextAlignmentCenter;
        [_headView addSubview:_titleLBel];
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn addTarget:self action:@selector(addDataClick) forControlEvents:UIControlEventTouchUpInside];
        [btn setTitle:@"back" forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        btn.frame = CGRectMake(0, 20, 120, 44);
        [_headView addSubview:btn];
        [self.view addSubview:_headView];
        
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, CScreenWidth, CScreenHeight-64)];
        UIView *headViewT = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CScreenWidth, 164)];
        headViewT.backgroundColor = [UIColor clearColor];
        _tableView.tableHeaderView = headViewT;
        _tableView.delegate =self;
        _tableView.dataSource = self;
        _tableView.backgroundColor = [UIColor clearColor];
        [self.view addSubview:_tableView];
        
    }
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        return 20;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        cell.textLabel.text =@"测试一下";
        return cell;
    }
    
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
        CGFloat offSetY = scrollView.contentOffset.y;
        NSLog(@"===%f",offSetY);
        if (offSetY < 164)
        {
            _titleLBel.textColor = [UIColor blueColor];
            _headView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:offSetY/164];
        }
        else
        {
            _titleLBel.textColor = [UIColor redColor];
            _headView.backgroundColor = [UIColor whiteColor];
        }
        if (offSetY > 0)
        {
            _bgImage.frame = ({
                CGRect frame = _bgImage.frame;
                frame.origin.y = orginYframe.origin.y - offSetY;
                frame;
            });
        }
        else
        {
            _bgImage.frame = ({
                CGRect frame = _bgImage.frame;
                frame.size.width =orginYframe.size.width -offSetY;
                frame.size.height = orginYframe.size.height *frame.size.width/ orginYframe.size.width;
                frame.origin.x = -(frame.size.width - orginYframe.size.width)/2;
                NSLog(@"----%@",NSStringFromCGRect(frame));
                frame;
            });
        }
        if (offSetY ==0)
        {
            _titleLBel.textColor = [UIColor redColor];
        }
    }
  • 相关阅读:
    Vue-CLI项目-axios模块前后端交互(类似ajax提交)
    Vue-CLI项目中路由传参
    HTML标签嵌套规则
    POJ1050 To the Max
    POJ2488 A Knight's Journey
    POJ1083 Moving Tables
    洛谷P1265 公路修建
    POJ2236 Wireless Network
    洛谷P1991 无线通讯网
    POJ1018 Communication System
  • 原文地址:https://www.cnblogs.com/xianfeng-zhang/p/8608671.html
Copyright © 2011-2022 走看看