欢迎光临
我们一直在努力

TabBar点击动画

建站超值云服务器,限时71元/月

TabBar点击动画

项目介绍:

XYTabBarAnimation

tabbar点击动画效果图

实现思路

利用UITabBarControllerUITabBarControllerDelegate,实现代理方法

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController  

下面是具体的实现代码

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController  
{  
    NSInteger index = [tabBarController.childViewControllers indexOfObject:viewController];  

    UIButton *tabBarBtn = tabBarController.tabBar.subviews[index+1];  
    UIImageView *imageView = tabBarBtn.subviews.firstObject;  
    // 切换过了,就停止上一个动画  
    if (self.currentIndex != index) {  
        // 把上一个图片的动画停止  
        [self.currentImageView stopAnimating];  
        // 把上一个图片的动画图片数组置为空  
        self.currentImageView.animationImages = nil;  
    } else {  
        return NO;  
    }  

    imageView.animationImages = self.allImages[index];  
    imageView.animationRepeatCount = 1;  
    imageView.animationDuration = ImageCount * 0.025;  

    // 开始动画  
    [imageView startAnimating];  

    // 记录当前选中的按钮的图片视图  
    self.currentImageView = imageView;  
    // 记录当前选中的下标  
    self.currentIndex = index;  

    return YES;  
}  
  • PS 动画的实现,是利用的帧动画,设计对选中的图片做好帧动画图片给到我们

代码传送门:https://github.com/XYXiaoYuan/XYTabBarAnimation

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » TabBar点击动画
分享到: 更多 (0)