iOS UITabBar:移除顶部阴影渐变线iOS 10

时间:2017-01-25 05:13:05

标签: ios objective-c iphone swift

任何人都可以为我提供UITabbar顶部阴影渐变线的解决方案。我已尝试设置tabBar.shadowImage = nil shadowImage自定义适用于iOS 9或之前版本。但不适用于iOS 10。

1 个答案:

答案 0 :(得分:0)

对于iOS 10,您可以使用Application委托类方法didFinishLaunchingWithOptions中的以下行:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.

    [[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"ImgName"]];
    [UITabBar appearance].layer.borderWidth = 0.0f;
    [UITabBar appearance].clipsToBounds = YES;

    return YES;
}

可能您可以尝试下面的代码,但不建议使用私有API:

[self.tabBar setValue:@(YES) forKeyPath:@"_hidesShadow"];

Shubham bairagi 建议删除顶部阴影渐变线iOS 10

tabBar.subviews[0].subviews[1].isHidden = true