iOS UITabBar : Remove top shadow gradient line

前端 未结 15 1274
暖寄归人
暖寄归人 2020-12-02 08:59

I implemented a custom UITabBar and I still have this gradient/shadow on top of it. I added

[self.tabBar setBackgroundImage:[UIImage imageNamed:@\"navBarBotto

相关标签:
15条回答
  • 2020-12-02 09:58

    Try this on viewDidload.

    override func viewDidLoad() {
            super.viewDidLoad()
    
            self.tabBar.setValue(true, forKey: "_hidesShadow")
    }
    

    It work for me

    0 讨论(0)
  • 2020-12-02 09:59

    Place this in your AppDelegate under didFinishLaunchingWithOptions:

    [[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
    [[UITabBar appearance] setBackgroundImage:[[UIImage alloc] init]];
    
    0 讨论(0)
  • 2020-12-02 10:03

    if you need to remove the shadow line on iOS 13 from a tab bar that has a custom font, then you have to apply it this way:

    if #available(iOS 13.0, *) {
       let appearance = UITabBarAppearance()
       appearance.stackedLayoutAppearance.normal.titleTextAttributes = ...
       appearance.stackedLayoutAppearance.selected.titleTextAttributes = ...
       appearance.shadowColor = .clear
       tabBar.standardAppearance = appearance
     }
    
    
    0 讨论(0)
提交回复
热议问题