似乎默认情况下,只要滚动到ToolbarItem后面,ToolbarItem就会被高亮显示,例如List.有什么方法可以禁用高亮显示吗?例如,应用信号使用ToolbarItem相同而不变、漂亮且具有薄material 效果的技术.或者他们使用的是自定义工具栏,并且无法更改,因为这似乎是系统默认设置.

Here is non-highlighted before scrolling list items: enter image description here

And here it gets highlighted when scrolling: enter image description here

.navigationBarTitle("Element", displayMode: .inline)
.toolbar {
                       
    ToolbarItem(placement: .navigationBarTrailing) {
        Menu {
            Button(action: { selectedFilter = .all }) {
                Label("Show All", systemImage: "line.3.horizontal")
            }

推荐答案

你可以把这init放到你的视图里

init() {
    let appearance = UINavigationBarAppearance()
    appearance.configureWithOpaqueBackground()
    appearance.backgroundColor = .clear // in your case, you can set it as black color for dark mode
    appearance.shadowColor = .clear // to remove thin line just under the NavigationBar
    
    UINavigationBar.appearance().standardAppearance = appearance
    UINavigationBar.appearance().compactAppearance = appearance
    UINavigationBar.appearance().scrollEdgeAppearance = appearance
}

standardAppearance:标准高度导航栏的外观设置. compactAppearance:紧凑高度导航栏的外观设置. scrollEdgeAppearance:可滚动内容的边缘与导航栏的边缘对齐时导航栏的外观设置.

链接:https://developer.apple.com/documentation/uikit/uinavigationbar/3198028-standardappearance

Ios相关问答推荐

在SwiftData中从@ Query创建可排序、有序和分组的数据

缺少预期的键:';NSPrival yCollectedDataTypes';

DriverKit驱动程序中可能存在IOBufferMemoyDescriptor泄漏

当包含UITextView的inputAccessoryView显示键盘时,iOS UITableView内容会出现UINavigationBar奇怪的错误

从后台线程调用DispatchObject的方法安全吗?

在SwiftUI中插入绘制重复形状

ScrollViewReader Scrollto Not Working

如何使用Swift以编程方式更改SVG文件中某些元素的 colored颜色

如何使用 SwiftData 从列表中删除子项目?

如何在Swift中同时实现三个手势?

SwiftUI - 搜索栏和导航标题之间的空间太大

多协议和类继承混乱,Swift

将 Riverpod 从 StateNotifier 修复为 NotifierProvider 以及应用程序生命周期监控

为什么 Firebase Messaging 配置对于 IOS native 和 Flutter iOS 不同?

将 URLCache 子类与 URLSession 一起使用

具有线性渐变的 SVG textPath 在 Safari 中损坏

如何为视图的 colored颜色 和宽度设置动画?

-1103 错误域=NSURLErrorDomain 代码=-1103资源超过最大大小iOS 13

光标未显示在 UITextView 中

单击 GoogleSignIn 按钮时应用程序崩溃