xcode 如何在自定义uiview中删除边框线?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41222351/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:39:51  来源:igfitidea点击:

how to remove border line in custom uiview?

iosswiftxcodeswift2

提问by Saeed

enter image description here

在此处输入图片说明

I made a custom view and I called it in UINavigationController, I made it transparent but after I put it inside navigation controller I got that border, how to remove it? thanks in advance

我创建了一个自定义视图,并在 UINavigationController 中调用它,我将其设置为透明,但是将其放入导航控制器后,我得到了该边框,如何将其删除?提前致谢

回答by Hosny

Try to set border width of your view with 0

尝试将视图的边框宽度设置为 0

yourView.layer.borderWidth = 0

回答by Sandro Machado

You need to set the border color of your view transparent.

您需要将视图的边框颜色设置为透明。

yourview.layer.borderColor = UIColor.clearColor()

This should work.

这应该有效。

回答by Md. Ibrahim Hassan

Try this code out. (91,158,236) is the color of your navigation bar.

试试这个代码。(91,158,236) 是导航栏的颜色。

yourview.layer.borderColor = UIColor(red: 91.0 / 255, green: 158.0 / 255, blue: 236.0 / 255, alpha: 1.0).CGColor

For a red View contained in navigation Bar for a borderWidth of 4.0 it would produce result like

对于包含在导航栏中的红色视图,边框宽度为 4.0,它会产生类似的结果

enter image description here

在此处输入图片说明

Hope this helps.

希望这可以帮助。

回答by Tuan Huynh

Update on Swift 3+

Swift 3+ 更新

yourview.layer.borderColor = UIColor.clear.cgColor