如何在 iOS 15 Xcode 13 中的 TabView tabItem 上将填充图标更改为未填充?
How to change filled icon to not filled on TabView tabItem in iOS 15 Xcode 13?
如何在 iOS 15 Xcode 13 中将 TabView tabItem 上的填充图标更改为未填充?
现在好像是默认填充图标了...
我的代码:
import SwiftUI
struct Test_Home_V: View {
var body: some View {
TabView {
HomeList_V()
.tabItem {
Label("_HomeTitle", systemImage: "house")
}
...
注意:从 iOS15 开始,您不应明确请求 SF Symbols 图标的填充变体,因为系统会自动适当地使用它们。
那么我怎样才能让我的图标(SF Symbols)像以前一样大纲呢?
谢谢
为了解决这个问题,我们可以使用environment(\.symbolVariants, .none)
。
https://developer.apple.com/documentation/swiftui/symbolvariants/none
Using this variant with the symbolVariant(:) modifier doesn’t have
any effect. Instead, to show a symbol that ignores the current
variant, directly set the symbolVariants environment value to none
using the environment(:_:) modifer:
import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
Text("content")
.tabItem {
Label("tab", systemImage: "creditcard")
}
Text("content")
.tabItem {
Label("tab", systemImage: "creditcard")
.environment(\.symbolVariants, .none) // here
}
}
}
}
结果:
如何在 iOS 15 Xcode 13 中将 TabView tabItem 上的填充图标更改为未填充?
现在好像是默认填充图标了...
我的代码:
import SwiftUI
struct Test_Home_V: View {
var body: some View {
TabView {
HomeList_V()
.tabItem {
Label("_HomeTitle", systemImage: "house")
}
...
注意:从 iOS15 开始,您不应明确请求 SF Symbols 图标的填充变体,因为系统会自动适当地使用它们。
那么我怎样才能让我的图标(SF Symbols)像以前一样大纲呢?
谢谢
为了解决这个问题,我们可以使用environment(\.symbolVariants, .none)
。
https://developer.apple.com/documentation/swiftui/symbolvariants/none
Using this variant with the symbolVariant(:) modifier doesn’t have any effect. Instead, to show a symbol that ignores the current variant, directly set the symbolVariants environment value to none using the environment(:_:) modifer:
import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
Text("content")
.tabItem {
Label("tab", systemImage: "creditcard")
}
Text("content")
.tabItem {
Label("tab", systemImage: "creditcard")
.environment(\.symbolVariants, .none) // here
}
}
}
}
结果: