ios - 如何在iOS10中的TabBar上删除行

标签 ios objective-c uitabbarcontroller ios10 uitabbar

创建一个具有自定义TabBar的项目,它在iOS高达9的情况下都可以完美工作,但是在iOS 10中,我在TabBar顶部的TabBar行有问题。

enter image description here

尝试以下代码:

UITabBarController *Tabbar;

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

它的工作是iOS9而不是iOS10
我试图将此应用到TabBar
1)试试:
   [Tabbar.tabBar setShadowImage:[[UIImage alloc] init]];
   Tabbar.tabBar.layer.borderWidth = 0.0f;
   Tabbar.tabBar.layer.borderColor =[UIColor clearColor].CGColor;
   Tabbar.tabBar.layer.backgroundColor=[UIColor clearColor].CGColor;
   Tabbar.tabBar.tintColor=CLEAR_COLOR;
   Tabbar.tabBar.barTintColor=CLEAR_COLOR;

2)尝试:
    CALayer * superLayer = [UITabBar appearance].layer;
    CALayer * layer = [CALayer layer];
    layer.bounds = CGRectMake (0.0f, 0.0f, 62.0f, 56.0f);
    layer.contents = (id) [UIImage imageNamed: @"tras_tabbg-min"].CGImage;
    layer.anchorPoint = CGPointMake (0.5f, 1.0f);
    layer.position = CGPointMake (superLayer.bounds.size.width / 2.0f, superLayer.bounds.size.height);
    layer.zPosition = 1.0f;
    [[UITabBar appearance].layer addSublayer: layer];

3)试试:(使应用程序崩溃)
[self.tabBar setValue:@(YES) forKeyPath:@"_hidesShadow"];

* 4)尝试:*
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"yourImageName"]];
[UITabBar appearance].layer.borderWidth = 0.0f;
[UITabBar appearance].clipsToBounds = true;

输出:

enter image description here

我也想要边境听证会。这是背景图片。

注意:我希望标签栏上的背景图片不是nil或clear

如果有任何解决方案,请回复。

最佳答案

如果> = iOS 10

tabBar.barStyle = UIBarStyle.black

其他
tabBar.shadowImage = UIImage()
tabBar.backgroundImage = UIImage()

关于ios - 如何在iOS10中的TabBar上删除行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40864187/

相关文章:

ios - 在我决定停止它之前,将当前线程 NSRunLoop 设置为以某种模式运行的正确方法是什么?

IOS:将 UICollectionViews 放入 UIPageVieControllers 中

ios - 在不使用 GLKIT 的情况下创建(从头开始)iOS 7.0 OpenGL ES 2.0 应用程序时出现问题

ios - 自定义 NSLog 方法(可变参数)

objective-c - 从 .mm 文件中的函数内部调用 C 函数

ios - 如何从选项卡栏 Controller 弹出或模态呈现 View Controller ?

ios - 如何在 Objective C 中格式化日期?

ios - 中心按钮标签栏

iphone - viewDidAppear 用于基于选项卡栏的应用程序

iphone - 一个基本的 UITabBar 应用程序