iOS UITabBar : Remove top shadow gradient line

前端 未结 15 1273
暖寄归人
暖寄归人 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:39

    Try setting a 1x1 pixel transparent shadow image for the UITabBar:

    [[UITabBar appearance] setShadowImage:[UIImage imageNamed:@"transparentShadow.png"]];
    
    0 讨论(0)
  • 2020-12-02 09:39

    This code works both iOS 13 and below

    if #available(iOS 13, *) {
        let appearance = self.tabBar.standardAppearance.copy()
        appearance.backgroundImage = UIImage()
        appearance.shadowImage = UIImage()
        appearance.shadowColor = .clear
        self.tabBar.standardAppearance = appearance
    } else {
        self.tabBar.backgroundImage = UIImage()
        self.tabBar.shadowImage = UIImage()
    }
    
    0 讨论(0)
  • 2020-12-02 09:39

    Just be setting image it will not remove the shadow line you have to set it's borderWidth to 0. here is the code

    [[UITabBar appearance] setShadowImage:[UIImage new]];

    [UITabBar appearance].layer.borderWidth = 0.0f;

    [UITabBar appearance].clipsToBounds = true;

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

    I have achieved the same look by following method.
    1. Set the background bar tint colour to same as the main parent view background colour.
    2.

    this.TabBar.BarStyle = UIBarStyle.BlackOpaque;
    

    I used it in Xamarin, Please verify the Swift syntax.

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

    Swift 4

    UITabBar.appearance().layer.borderWidth = 0.0
    UITabBar.appearance().clipsToBounds = true
    
    0 讨论(0)
  • 2020-12-02 09:40

    In iOS 7 - this works:

    [self.actionToolbar setShadowImage:[[UIImage alloc] init] forToolbarPosition:UIBarPositionAny];
    [self.actionToolbar setBackgroundImage:[[UIImage alloc] init] forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
    

    Hope that helps someone.

    0 讨论(0)
提交回复
热议问题