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;

            }
            
            
        }
        
        
        
    }

}

免责声明:文章转载自《tabBarItem动画》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇DB2字符处理函数使用Unity3D的50个技巧:Unity3D最佳实践!下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

使用Kdenlive为视频加入马赛克特效

Kdenlive(KDE Non-Linear Video Editor)是一种基于MLT框架、KDE和Qt的自由开源的非线性影片编辑器。其底层包含了FFmpeg,所以可以支持FFmpeg中的所有视频及音频格式。与Adobe公司的非线性剪辑软件Premiere相比,此款软件是完全免费,并且可以在Linux,Windows及Mac OSX上运行。 因为最近遇...

在WPF中如何使用RelativeSource绑定

在WPF绑定的时候,指定绑定源时,有一种办法是使用RelativeSource。 这种办法的意思是指当前元素和绑定源的位置关系。 第一种关系: Self 举一个最简单的例子:在一个StackPanel中,有一个TextBlock。 <TextBlock FontSize="18" FontWeight="Bold" Margin="10"...

css动画效果之transition(动画过渡效果属性)

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <!-- transition:动画过渡效果属性 功能:使cs...

[转]innerHtml,innerText,outterHtml,outterText 的区别

js中innerHTML与innerText的用法与区别 用法: Java代码 <divid="test"> <spanstyle="color:red">test1</span>test2 </div> <div id="test"> <span style...

cocos creator 3D | 蚂蚁庄园运动会星星球

上一篇文章写了一个简易版的蚂蚁庄园登山赛,有小伙伴留言说想要看星星球的,那么就写起来吧! 效果预览 配置环境 cocos creator 3d 1.0.0 小球点击 3d里节点无法用 cc.Node.EventType.TOUCH_START 监听。最终在论坛上找到一个 raycast 解决方法。参考代码如下。 start() { system...

Drawable

今天简单的介绍一下有关以下5中的应用: Statelistdrawable Layerdrawable Shapeddrawable Clipdrawable Animationdrawable 1. Statelistdrawable的应用: 描述:当使用此类型定义View的前景,背景图时由对象的当前状态的改变对应的图片也随之改名。 定义:XML的根...