将remove navigationBar border转换为swift [英] Convert remove navigationBar border to swift

查看:175
本文介绍了将remove navigationBar border转换为swift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在swift中删除navigationBar边框。这是通过在objective-c中使用以下代码来完成的:

i'm trying to remove the navigationBar border in swift. This is done by using following code in objective-c:

[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault]

如何在swift中完成?

How can this be done in swift?

我试过这个,但没有工作:

i've tried this, but not working:

UINavigationBar.appearance().shadowImage = UIImage(named: "")
UINavigationBar.appearance().setBackgroundImage(UIImage(named: ""), forBarMetrics: UIBarMetrics.Default)


推荐答案

试试这个:

UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)

这篇关于将remove navigationBar border转换为swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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