iOS 7 tabBar-line, how to remove it?

2019-03-08 22:53发布

Apple has added a tiny line over the tabBar in iOS 7 which is supposed to work as a shadow or fade between the tabBar and the UI

enter image description here

Since I am using a custom-made tabBar the line is quite irritating. How do you remove it? Please tell me it is possible, otherwise I need to redesign my whole app lol....

/ Regards

*Edit

Sloved my problem with the following line of code:

[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];

12条回答
Root(大扎)
2楼-- · 2019-03-08 23:08
    UIImage* tabBarBackground = [UIImage imageNamed:@"tabbar_bg.png"];
    [[UITabBar appearance] setShadowImage:tabBarBackground];
    [[UITabBar appearance] setBackgroundImage:tabBarBackground];   
查看更多
ゆ 、 Hurt°
3楼-- · 2019-03-08 23:09
 [_tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:@"tabtarsprnt"]]; //your custom image
[self.tabBarController.tabBar setClipsToBounds:YES];

this code also solved the my issue

查看更多
欢心
4楼-- · 2019-03-08 23:11
self.tabBarController =  [[UITabBarController alloc] init];
[[[self tabBarController] tabBar] setBackgroundImage:[UIImage imageNamed:@"YOURIMAGE.png"]];
[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
查看更多
乱世女痞
5楼-- · 2019-03-08 23:17

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 document 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).

查看更多
ら.Afraid
6楼-- · 2019-03-08 23:20

This worked for me

UIImage* tabBarBackground = [UIImage new];
if(!OSVersionIsAtLeastiOS7())
{
    tabBarBackground = [UIImage imageNamed:@"whitebg"];
}
[[UITabBar appearance] setShadowImage:tabBarBackground];

[[UITabBar appearance] setBackgroundImage:tabBarBackground];
查看更多
来,给爷笑一个
7楼-- · 2019-03-08 23:22

I'm not seeing anything in the UITabBar API for affecting that separator, but if the separator is within the UITabBar (a UIView subclass), I'd expect you can insert a new one-pixel-high UIView on top of it. You'd have to grab a slice of the image that you want to appear there and draw it in the new view. And I'm not sure if UITabBar would somehow prevent adding the subview or prevent the subview from being on top. But that's where I'd start.

查看更多
登录 后发表回答