Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

引入lottie动画,设置badge失效 #371

Closed
helloDolin opened this issue May 9, 2019 · 13 comments
Closed

引入lottie动画,设置badge失效 #371

helloDolin opened this issue May 9, 2019 · 13 comments
Labels

Comments

@helloDolin
Copy link

enter image description here



Base Info for this issue

  1. Version:1.2.4(https://github.com/ChenYilong/CYLTabBarController/blob/master/CYLTabBarController.podspec)
  2. Language of App :Objective-C
  3. iOS System Version:iOS12.2
  4. Prototype(是否是真机):模拟器
  5. Issue Type:(希望能支持一个新需求)、Q-A

1. How to reproduce the problem.

1.tabBarItemsAttributesForController (我这边item是通过lottie进行动画的,很高兴看到最新版支持lottie),添加了 CYLTabBarLottieURL 这个 key
2.[self cyl_tabBarController] setViewDidLayoutSubViewsBlockInvokeOnce...
按照建议在这边设置badge

然后,badge就失效了,因为我去掉 CYLTabBarLottieURL 这个key之后,badge都正常了

2. Please help me in this way.

badge 不与 lottie 相互影响

3. Here is a Demo.

我直接在项目中集成的,demo,不好提供,希望问题我已经讲清楚了

4. Here is my Debug log


@ChenYilong
Copy link
Owner

setViewDidLayoutSubViewsBlockInvokeOnce
内部是否使用了延时操作,问题可能出在延时上,你重点调整下延时时间。看看能否解决。

@helloDolin
Copy link
Author

setViewDidLayoutSubViewsBlockInvokeOnce
内部是否使用了延时操作,问题可能出在延时上,你重点调整下延时时间。看看能否解决。

内部没有使用延迟操作

@ChenYilong
Copy link
Owner

加一个延时试试

@helloDolin
Copy link
Author

如图.png

@ChenYilong
Copy link
Owner

badge的设置方法贴一下,我确认下你的api。

@ChenYilong
Copy link
Owner

参考demo做法,demo里跟你的效果一致。

@helloDolin
Copy link
Author

好的,谢谢回复,真的好及时!

@ChenYilong
Copy link
Owner

你确认下是不是最新版吧,我记得这个问题修复了。

@ChenYilong
Copy link
Owner

@ChenYilong ChenYilong added the Q-A label May 13, 2019
@ChenYilong
Copy link
Owner

建议 app启动后就给icon加红点的情况下,加一个延时,lottie图片加载可能比一般的静态图片略微延迟。
总体可忽略不及,但一旦json文件过大,加载时间也会延长。加一秒延迟,再显示红点,比较稳妥。

  //添加提示动画,引导用户点击
   [tabBarController setViewDidLayoutSubViewsBlockInvokeOnce:YES block:^(CYLTabBarController *tabBarController) {
       NSUInteger delaySeconds = 1;
       dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delaySeconds * NSEC_PER_SEC));
       dispatch_after(when, dispatch_get_main_queue(), ^{
           @try {
               UIViewController *viewController0 = tabBarController.viewControllers[0];
               // UIControl *tab0 = viewController0.cyl_tabButton;
               // [tab0 cyl_showBadge];
               [viewController0 cyl_setBadgeBackgroundColor:RANDOM_COLOR];
               [viewController0 cyl_setBadgeCenterOffset:CGPointMake(-5, 3)];
               [viewController0 cyl_setBadgeRadius:5/2];
               [viewController0 cyl_setBadgeMargin:1];
               [viewController0 cyl_showBadge];
               
               [tabBarController.viewControllers[1] cyl_showBadgeValue:@"" animationType:CYLBadgeAnimationTypeScale];
               [tabBarController.viewControllers[1] cyl_setBadgeBackgroundColor:RANDOM_COLOR];
               [tabBarController.viewControllers[2] cyl_showBadgeValue:@"test" animationType:CYLBadgeAnimationTypeShake];
               [tabBarController.viewControllers[3] cyl_showBadgeValue:@"100" animationType:CYLBadgeAnimationTypeBounce];
               [tabBarController.viewControllers[4] cyl_showBadgeValue:@"new" animationType:CYLBadgeAnimationTypeBreathe];
           } @catch (NSException *exception) {}

           //添加仿淘宝tabbar,第一个tab选中后有图标覆盖
           if ([self cyl_tabBarController].selectedIndex != 0) {
               return;
           }
//            tabBarController.selectedIndex = 1;
       });
   }];

@helloDolin
Copy link
Author

嗯嗯,谢谢回复

@ChenYilong
Copy link
Owner

客气,后期有问题,多多反馈。

@ChenYilong
Copy link
Owner

欢迎加我微信交流.我的id是chenyilong1010。另外使用 CYLTabBarController 做的 APP,来这里报道下吧! #314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants