zoukankan      html  css  js  c++  java
  • tabBarItem动画

     1.有时,我们需要为tabBarItem设置一些动画。在网上查了半天,没有结果。自己写了一个简单的动画

    代码如下:

    - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
        
        NSInteger currentIndex = tabBarController.selectedIndex;
        NSInteger index = 0;
        UITabBar *tabBar = tabBarController.tabBar;
        
        for (int i = 0; i < tabBar.subviews.count; i++) {
            
            UIView *button = tabBar.subviews[i];
            if ([button isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
                
                if (index != currentIndex) {
                    index++;
                }
                else{
                    
                    CAKeyframeAnimation *animation = [[CAKeyframeAnimation alloc]init];
                    
                    animation.keyPath = @"transform.scale";
                    animation.duration = 1.0;
                    animation.values = @[@(1.0) ,@(1.4), @(0.9), @(1.15), @(0.95), @(1.02), @(1.0)];
                    
                    
                    UIView *imageview = [button.subviews firstObject];
                    //view.backgroundColor = [UIColor greenColor];
                    [imageview.layer addAnimation: animation forKey:nil];
                    
                    UIView *labelview = [button.subviews lastObject];
                    [labelview.layer addAnimation:animation forKey:nil];
                    break;
    
                }
                
                
            }
            
            
            
        }
    
    }
  • 相关阅读:
    lua 计算字符串字符个数“中文字算一个字符”
    C API
    词汇
    LUA 创建文件和文件夹
    lua lfs库
    Unity3d gameObject
    Unity3d Time
    Unity3d Vector3
    Unity3d transform
    从Oracle数据库中的本地命名文件tnsnames.ora来看服务别名、服务名和实例名的区别。
  • 原文地址:https://www.cnblogs.com/yintingting/p/4567155.html
Copyright © 2011-2022 走看看