How do I change the foreground color of a SwiftUI Tab?
I have my code as follows:
/// Inside TabView
// Home Tab
Tab("", systemImage: "house.fill", value: .home) {
HomeScreen()
}.foregroundStyle(.red)
I get errors when I tried to add the foregroundStyle(.red).
I also tried using the label parameter and creating a label with the foregroundStyle(.red) modifier. Compiles but still no color changes.
Post
Replies
Boosts
Views
Activity
After reading the documentation on .digitalCrownAccessory, I am under the impression that the system should know to show your accessory and hide your accessory according to whether the crown is being rotated. I have noticed this is not the case. I have also tried a few work arounds with no luck. Here is a simplified version of my code. I have recorded a video of the issue I am seeing, but I can't upload it, so I have attached some screenshots instead.
Expected result: After rotating the crown, the accessory image should disappear along with the vertical system scroll bar.
Actual result: After rotating the crown, the vertical system scroll bar disappears but the accessory image stays behind.
Versions:
Sonoma 14.6.1
Xcode 16 Beta 5 (and Xcode 15.4)
Apple Watch Ultra 2 watchOS 11 (device and simulator)
Starting file (main):
import SwiftUI
@main
struct DummyWatch_Watch_AppApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
ContentView.swift:
import SwiftUI
struct ContentView: View {
@State var crownValue: CGFloat = 0
var body: some View {
VStack {
Text("Hello, world!")
}
.focusable()
.digitalCrownRotation($crownValue,
from: 0,
through: 10,
by: 0.1,
sensitivity: .low,
isContinuous: false)
.digitalCrownAccessory {
Image(systemName: "speaker.fill")
}
.padding()
}
}
Images:
Scrolling:
Speaker wont go away: