如何让UINavigationBar的shadowImage固定?

发布于 2025-01-14 04:45:00 字数 870 浏览 6 评论 0原文

我有一个反向的 UITableView:

tableView.transform = CGAffineTransform(rotationAngle: -(CGFloat)(Double.pi))

NavigationBar 设置:

navigationBar.shadowImage = UIImage()
navigationBar.layer.masksToBounds = false
navigationBar.layer.shadowColor = Assets.Colors.black.color.withAlphaComponent(0.2).cgColor
navigationBar.layer.shadowOpacity = 0.7
navigationBar.layer.shadowOffset = CGSize(width: 0, height: 2.0)
navigationBar.layer.shadowRadius = 5
navigationBar.isTranslucent = false
view.backgroundColor = color

每当我滚动到 TableView 的底部(反转时滚动到顶部)时,阴影就会消失。我希望它保持不变(如第二个屏幕截图所示)。
无论 TableView 滚动如何,是否可以使 UINavigationBar 阴影保持静态?

现在的样子:
没有阴影

应该是这样的:
带阴影

I have a reversed UITableView:

tableView.transform = CGAffineTransform(rotationAngle: -(CGFloat)(Double.pi))

NavigationBar setup:

navigationBar.shadowImage = UIImage()
navigationBar.layer.masksToBounds = false
navigationBar.layer.shadowColor = Assets.Colors.black.color.withAlphaComponent(0.2).cgColor
navigationBar.layer.shadowOpacity = 0.7
navigationBar.layer.shadowOffset = CGSize(width: 0, height: 2.0)
navigationBar.layer.shadowRadius = 5
navigationBar.isTranslucent = false
view.backgroundColor = color

Whenever I scroll to the bottom of my TableView (to the top when inverted), shadow disappears. I want it to be constant (like at the second screenshot).
Is it possible to make UINavigationBar shadow static regardless of TableView scrolling?

How it looks now:
No shadow

How it should be:
With shadow

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

本宫微胖 2025-01-21 04:45:00

在iOS15/Xcode13中,导航栏的外观存在一个常见问题。您可以在此处阅读更多信息并应用修复程序。

In iOS15/Xcode13, there is a common problem with the navigation bar's appearance. You can read more here and apply the fixes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文