ChenYilong / CYLTabBarController

[EN]It is an iOS UI module library for adding animation to iOS tabbar items and icons with Lottie, and adding a bigger center UITabBar Item. [CN]【中国特色 TabBar】一行代码实现 Lottie 动画TabBar,支持中间带+号的TabBar样式,自带红点角标,支持动态刷新。【iOS13 & Dark Mode & iPhone XS MAX supported】
MIT License
6.91k stars 1.45k forks source link

tabbar不设置背景图的话,怎么加阴影效果。 #338

Closed KinmoCode closed 5 years ago

KinmoCode commented 5 years ago

Base Info for this issue

  1. Version:v1.17.22
  2. Language:Objective-C
  3. iOS System Version:iOS12
  4. Prototype(是否是真机):YES
  5. Issue Type:Crash、Bug、Enhancement(希望能支持一个新需求)、Q-A

1. How to repeat the problem.

2. Please help me in this way.

3. Here is a Demo.

4. Here is my Debug log

ChenYilong commented 5 years ago

icon 加,还是tabbaritem backgroundimage 加?视觉图有吗?

KinmoCode commented 5 years ago

@ChenYilong 已解决,加在tabbar上面,不过要在AppDelegate的里面加,要不然拿不到tabbar.

ChenYilong commented 5 years ago

项目任何地方都可以拿到tabbar,readme里有写。

ChenYilong commented 5 years ago

Demo中也有演示:

//Three way to deal with shadow 三种阴影处理方式:
    // NO.3, without shadow
        [[UITabBar appearance] setShadowImage:[UIImage new]];
    //NO.2,using Image
    //    [[UITabBar appearance] setShadowImage:[UIImage imageNamed:@"TabBar_Bg_Shadow"]];
    //NO.1,using layer to add shadow. note:recommended. 推荐该方式,可以给PlusButton突出的部分也添加上阴影
    tabBarController.tabBar.clipsToBounds = NO;
    tabBarController.tabBar.layer.shadowColor = [UIColor blackColor].CGColor;
    tabBarController.tabBar.layer.shadowRadius = 5.0;
    tabBarController.tabBar.layer.shadowOpacity = 0.2;
    tabBarController.tabBar.layer.masksToBounds = NO;
    tabBarController.tabBar.layer.shadowOffset = CGSizeMake(0, 3);