简体   繁体   English

如何在带有背景图像的> iOS 10和Swift 4中删除标签栏顶部边框(阴影)?

[英]How to remove Tab Bar top border (shadow) in > iOS 10 and Swift 4 with a background image?

I've been trying to remove the top border (shadow) line from Tab Bar in Swift 4 for > iOS 10. I'm also using a custom background image. 我一直在尝试从iOS 4的Swift 4的选项卡栏中删除顶部边框(阴影)线。我也在使用自定义背景图片。 I've just given up after searching for solutions, since none of them work. 我只是在寻找解决方案之后就放弃了,因为它们都不起作用。

The solution which came closest was this post . 最接近的解决方案是此职位

The solution given everywhere works if there is no background or for < iOS 10. For iOS > 10 and using a custom background image none of solutions work. 如果没有背景或对于<iOS 10,无处不在的解决方案都适用。对于iOS> 10并使用自定义背景图像,所有解决方案均无效。

I even tried using a transparent shadow image, but it required setting cliptobounds to true which doesn't show custom background image. 我什至尝试使用透明阴影图像,但是它要求将cliptobounds设置为true,这不会显示自定义背景图像。

So at the end of all these solution I'm stuck. 因此,在所有这些解决方案的最后,我都陷入了困境。 Couldn't find any working solution. 找不到任何有效的解决方案。

I'm setting these custom values in AppDelegate so that it works for all Tab Bars. 我在AppDelegate中设置这些自定义值,以便它适用于所有选项卡栏。

I just created a sample project using tab bar template from Xcode and write three lines of code 我刚刚使用Xcode的标签栏模板创建了一个示例项目,并编写了三行代码

self.tabBar.layer.borderWidth = 0
self.tabBar.clipsToBounds = true
self.tabBar.backgroundColor = .blue

And tab bar top border is no longer visible. 并且选项卡栏的顶部边框不再可见。 I've tested this on Simulator iphone 6 with ios 11.2 我已经在带有iOS 11.2的Simulator iphone 6上进行了测试

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM