In my app, I want to add a performance the place when a button is tapped, menu must be introduced with a listing of things.
All that is working high-quality besides the textual content/foreground shade of the button occurs to be similar because the background shade of the view on which button is positioned. In my pattern code under it occurs to be white shade. When menu is introduced, seems to be like iOS fades or reduces opacity of button’s background and foreground and due to this the textual content on the button will not be seen.
I want have the button textual content seen in some shade and therefore I added button model, but it surely would not work when menu is introduced. It really works on common button faucets, however not with menu. Tips on how to change the button foreground/background when menu is introduced? I’m utilizing iOS 16+.
Code:
import SwiftUI
import Basis
struct ContentView: View {
@State personal var showSignInOptionsView = false
var physique: some View {
VStack {
Menu {
Button {} label: {
Textual content("Menu 1")
}
Button {} label: {
Textual content("Menu 2")
}
Button {} label: {
Textual content("Menu 3")
}
} label: {
Button { showSignInOptionsView.toggle() } label: {
Textual content("Signal In").body(maxWidth: .infinity).contentShape(Rectangle())
}
.buttonStyle(SignInButtonStyle())
}
// Observe: button model works on this because it's common button. Uncomment to check.
// Button { showSignInOptionsView.toggle() } label: {
// Textual content("Signal In - Common Button").body(maxWidth: .infinity).contentShape(Rectangle())
// }
// .buttonStyle(SignInButtonStyle())
}
}
}
personal struct SignInButtonStyle: ButtonStyle {
func makeBody(configuration: Self.Configuration) -> some View {
configuration.label
.font(.physique.daring())
.foregroundColor(configuration.isPressed ? .black : .white)
.body(width: UIScreen.principal.bounds.width - 50.0, top: 30.0)
.padding(10.0)
.background(configuration.isPressed ? .grey : .blue)
.cornerRadius(10.0)
}
}
Screenshots: I want to have button textual content clearly seen in the proper screenshot i.e. when menu is open.