ios - Swift UINavigation 底线和阴影移除,无需导航栏颜色更改
问题描述
UINavigationBar
我的场景,我试图从使用iOS 13 - Swift 5中删除底线和阴影。在这里,在iOS 13 - Swift 5之前,我使用下面的代码来移除底线和阴影而不改变导航栏颜色。现在,它没有显示NavigationBar
颜色(我已经设置了条形颜色和背景颜色)也禁用了 Transulent。
代码:
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
如何解决这个问题?需要去除底线阴影并且还想给 NavigationBar 颜色。
解决方案
对我来说,它只有在更改以下(> = iOS13)后才有效
let navBarAppearance = UINavigationBarAppearance()
navBarAppearance.configureWithOpaqueBackground()
navBarAppearance.shadowColor = .clear
navBarAppearance.shadowImage = UIImage()
navigationController?.navigationBar.standardAppearance = navBarAppearance
navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
推荐阅读
- flutter - 如何在颤振中使用扩展
- azure-traffic-manager - Azure 前门 URL 重写
- flutter - 为 IPFS 构建 Flutter 客户端
- node.js - Fastify 异步尝试捕获无法解决
- javascript - 如何在动态创建的输入标签上捕获“输入”键 - Vanilla JS
- python - 打包 python 代码依赖项以便即时远程执行
- databricks - 无法在 Databricks 社区版上创建集群
- jmeter - 将外部 ID 保存到 Jmeter 中的结果文件
- amazon-athena - Athena - String to Date 覆盖
- cloud - 是否可以同时在不同的云提供商上使用 SaaS、IaaS 和 PaaS 的单一服务?