zoukankan      html  css  js  c++  java
  • 第三十八篇、给UITabBar按钮的动画效果

     在很多情况下,我们也时常有这样的需求,就是在UITabBar切换的时候,添加一些动画效果

    1.在UITabBar触发点击方法的时候捕获当前点击的item

    2.使用coreAnimation设置动画效果

    - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
    
        NSInteger index = [self.tabBar.items indexOfObject:item];
    
        if (self.indexFlag != index) {
            [self animationWithIndex:index];
        }
    
    }
    // 动画
    - (void)animationWithIndex:(NSInteger) index {
        NSMutableArray * tabbarbuttonArray = [NSMutableArray array];
        for (UIView *tabBarButton in self.tabBar.subviews) {
            if ([tabBarButton isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
                [tabbarbuttonArray addObject:tabBarButton];
            }
        }
        CABasicAnimation*pulse = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
        pulse.timingFunction= [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        pulse.duration = 0.08;
        pulse.repeatCount= 1;
        pulse.autoreverses= YES;
        pulse.fromValue= [NSNumber numberWithFloat:0.7];
        pulse.toValue= [NSNumber numberWithFloat:1.3];
        [[tabbarbuttonArray[index] layer]
         addAnimation:pulse forKey:nil];
    
        self.indexFlag = index;
    
    }
  • 相关阅读:
    ARC109C Large RPS Tournament 机智
    ABC186F Rook on Grid 树状数组
    二分查找
    CF1445D. Divide and Sum 组合数
    APP测试方法分享
    面试常见问题
    接口测试基础知识
    接口测试一
    web端测试
    Jmeter简介
  • 原文地址:https://www.cnblogs.com/HJQ2016/p/5918027.html
Copyright © 2011-2022 走看看