源码

首页 » 归档 » 源码 » Tabbar点击时候超炫小动画-ios学习从入门到精通尽在姬长信

Tabbar点击时候超炫小动画-ios学习从入门到精通尽在姬长信

分享最热门的ios资讯

对UITabBarController上TabBar按钮动画详细介绍-->>保证你有意外收获,如有问题欢迎指点。。


废话就不多说了直接上效果图,这是我公司项目中加的动画,自己可以适当的加以修改称自己想要的

#效果

1766284-60f5ae9477f56ba9.gif

点击下面的按钮时候是不是有动画 可能这个Gif动画有延迟 效果不明显 下面上代码。。
##代码
- (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;

}

文章转自 MrBrave丶彬彬的简书
用意志战胜身体的惰性!

(1)

本文由 姬長信 创作,文章地址:https://blog.isoyu.com/archives/1220.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 22, 2016 at 08:00 下午

关键词:

热评文章

发表回复

[必填]

我是人?

提交后请等待三秒以免造成未提交成功和重复