删除视图和搜索栏之间的边框 [英] Remove border between View and Search Bar

查看:178
本文介绍了删除视图和搜索栏之间的边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以在Xcode中我正在尝试创建一个无缝搜索栏。所以我试图复制这样的东西

So in Xcode I'm trying to create a seamless search bar. So I'm trying to replicate something like this

请注意状态栏与搜索栏的颜色相同。现在这是我的方法的结果。

Note how the status bar is the same color as the search bar. Now here's the result to my approach.

什么我做的是添加一个视图来掩盖蓝色背景的默认状态栏。然后我添加了一个搜索栏并将其背景更改为蓝色。出于某种原因,我最终在两者之间形成了黑色边框,这破坏了无缝设计。关于如何在Swift中删除黑色边框的任何想法?

What I did was add a View to cover up the default status bar with the blue background. Then I added a search bar and changed it's background to blue. For some reason I end up getting a black border between the two, which ruins the "seamless" design. Any ideas on how I can remove the black border in Swift?

推荐答案

对于iOS 7 +:

searchBar.backgroundImage = UIImage()

否则这适用于所有iOS版本:

Otherwise this will work on all iOS versions:

searchBar.layer.borderWidth = 1
searchBar.layer.borderColor = thatBlueColor.CGColor

这篇关于删除视图和搜索栏之间的边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆