美文网首页
小论动画分析

小论动画分析

作者: BoxDeng | 来源:发表于2017-10-18 22:35 被阅读0次

    一手指天,一手指地。

    天就是网络, 天网呗

    地,就是数据库




    

    Code4App 动画分析, 好烂啊

    

    Code4App上面找的动画,基本都是UIView 层的,简单的 设置属性,

    非常的基础, 适合 初学者 练习。

    觉得 比较好看的动画,
    翻源码, 发现 :实现 很 Low, 工程性 很差。

    + (void)showTitle:(NSString *)title KRPopupViewModelArray:(NSMutableArray *)modelArray Target:(UIViewController<KRPopupViewCellDelegate> * )target{
        
        KRPopupView * krPopupView = [[KRPopupView alloc] initWithFrame:CGRectMake(0, 20, kScreenWidth, kScreenHeight )];
        
        UIViewController * vc = target;
        [vc.view addSubview: krPopupView];
    
        NSMutableArray * viewArray = [NSMutableArray new];
        
        for (int i = 0; i < modelArray.count + 1; i++) {
            
            if (i == 0) {
                
                KRPopupHeaderView * headerView = [[[NSBundle mainBundle] loadNibNamed:@"KRPopupHeaderView" owner:self options:nil] firstObject];
                
                headerView.frame           = CGRectMake(0, [UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width, KR_HEADERVIEW_HEIGHT);
                headerView.alpha           = 0.2f;
                headerView.delegate        = krPopupView;
                headerView.titleLabel.text = title;
                
                [viewArray addObject:headerView];
                [krPopupView addSubview:headerView];
                
            }else{
                
                KRPopupViewCell * cell = [[[NSBundle mainBundle] loadNibNamed:@"KRPopupViewCell" owner:self options:nil] firstObject];
                cell.frame = CGRectMake(0, kScreenHeight, kScreenWidth, 120);
                cell.alpha = 0.2f;
                cell.tag  = i - 1;
                cell.delegate = target;
                cell.model = modelArray[i-1];
                
                [viewArray addObject:cell];
                [krPopupView addSubview:cell];
            }
        }
        
        [krPopupView showWithViewArray:viewArray];
    }
    
    
    - (void)showWithViewArray:(NSMutableArray *)array{
        
        static double durationTime;
        
        durationTime = 0.0;
        
        for (int i = 0; i < array.count; i++) {
            
            if (i == 0) {
                
                KRPopupHeaderView * headerView = [array firstObject];
                [UIView animateWithDuration:KR_DURATION_TIME animations:^{
                    headerView.frame = CGRectMake(0, 0, kScreenWidth, KR_HEADERVIEW_HEIGHT);
                    headerView.alpha = 1.f;
                }];
                
            }else{
                
                KRPopupViewCell * cell = array[i];
                [UIView animateWithDuration:KR_DURATION_TIME delay:durationTime options:UIViewAnimationOptionCurveEaseOut animations:^{
                    cell.frame = CGRectMake(0, (i - 1) * KR_CELLVIEW_HEIGHT + KR_HEADERVIEW_HEIGHT, kScreenWidth, KR_CELLVIEW_HEIGHT);
                    cell.alpha = 1.f;
                } completion:nil];
                
            }
            
            //增加延迟
            durationTime += KR_DURATION_TIME - 0.1;
        }
        
    }
    

    相关文章

      网友评论

          本文标题:小论动画分析

          本文链接:https://www.haomeiwen.com/subject/hmlyuxtx.html