TableView滚动时导航栏颜色发生变化。我不知道如何解决此问题。请告诉我。(UIKit)
fivyi3re1#
我认为这是iOS 15+中导航栏的默认行为。为了防止这种情况,您可以在故事板中选择导航栏,在属性检查器中选择check Standard & Scroll Edge,然后在Standard Appearance和Scroll Edge Appearances部分更改背景颜色,或者查看此图片:Storyboard configuration如果你想用编程的方式来完成,你可以在viewDidLoad中调用这段代码:
check Standard & Scroll Edge
Standard Appearance
Scroll Edge Appearances
let appearance = UINavigationBarAppearance() appearance.backgroundColor = .blue navigationController?.navigationBar.standardAppearance = appearance navigationController?.navigationBar.scrollEdgeAppearance = appearance
如果你想在全局范围内执行,你可以在AppDelegate中调用这段代码:
let appearance = UINavigationBarAppearance() appearance.backgroundColor = .red UINavigationBar.appearance().standardAppearance = appearance UINavigationBar.appearance().scrollEdgeAppearance = appearance
1条答案
按热度按时间fivyi3re1#
我认为这是iOS 15+中导航栏的默认行为。为了防止这种情况,您可以在故事板中选择导航栏,在属性检查器中选择
check Standard & Scroll Edge
,然后在Standard Appearance
和Scroll Edge Appearances
部分更改背景颜色,或者查看此图片:Storyboard configuration如果你想用编程的方式来完成,你可以在viewDidLoad中调用这段代码:
如果你想在全局范围内执行,你可以在AppDelegate中调用这段代码: