Skip to content

Instantly share code, notes, and snippets.

@mattyoung
Created October 12, 2021 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattyoung/5cbbcbade56be49f2496eb1494ddaa3c to your computer and use it in GitHub Desktop.
Save mattyoung/5cbbcbade56be49f2496eb1494ddaa3c to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Group {
Text(".tint(_:)")
Button("Default") { }
// .tint(nil) works better than .accentColor(nil): it's app's accentColor
Button(".tint(nil)") { }
.tint(nil) // how to instead inherit from parent view, .mint?
}
.tint(.mint)
Divider()
Group {
Text(".accentColor(_:)")
Button("Default") { }
// 👎 always blue
Button(".accentColor(nil)") { }
.accentColor(nil)
}
.accentColor(.mint)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment