Tabbar页面切换弹性动画

写在自己封装的TabBarViewController里即可


@interface WTTabBarViewController ()
@property (assign,nonatomic) NSInteger index;
@end

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
    NSInteger selectIndex = [tabBar.items indexOfObject:item];
    if (selectIndex != _index)  // 是否重复点击 (需要重复点击直接注释)
        [self animationWithIndex:selectIndex];
}

- (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.2;   //time
    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];
    
    _index = index;
    
}


gif5新文件-2.gif

借鉴http://www.cnblogs.com/yajunLi/p/6288811.html 感谢分享

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,790评论 25 709
  • 前些日子从@张鑫旭微博处得一份推荐(Front-end-tutorial),号称最全的资源教程-前端涉及的所有知识...
    谷子多阅读 9,773评论 0 44
  • 我不是在说我自己-写在前面~ 要有多坚强,才敢念念不忘 你可曾知道,我总在下雨时分 宁静与忧伤之间,最想念你 你可...
    欲为小汉阅读 1,742评论 0 0
  • 失业加失恋, 再加本身就是很宅的人 呵呵有得熬了 想得够多 多的是时间想 呵呵 等着崩溃吧 呵呵呵呵
    阿渴阅读 2,642评论 0 1
  • 小岩#每天500字#D6 去年在各种社群风行的时候知道了熊猫书院,觉得这个10个月的阅读活动太好了,就报名参加了,...
    岩岩Fighting阅读 1,735评论 0 0