iOS UITabBar : Remove top shadow gradient line

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

    Try this, ** Objective-C **

    //Remove shadow image by assigning nil value.
    [[UITabBar appearance] setShadowImage: nil];
    
    // or 
    
    // Assing UIImage instance without image reference
    [[UITabBar appearance] setShadowImage: [[UIImage alloc] init]];
    

    ** Swift **

    //Remove shadow image by assigning nil value.
    UITabBar.appearance().shadowImage = nil
    
    // or 
    
    // Assing UIImage instance without image reference
    UITabBar.appearance().shadowImage = UIImage()
    


    Here is apple guideline for shadowImage.

    @available(iOS 6.0, *)
    open var shadowImage: UIImage?
    

    Default is nil. When non-nil, a custom shadow image to show instead of the default shadow image. For a custom shadow to be shown, a custom background image must also be set with -setBackgroundImage: (if the default background image is used, the default shadow image will be used).

提交回复
热议问题