in SwiftUI,my var has UIScreen.main.bounds.width.
@State private var buttonWidth: Double = UIScreen.main.bounds.width.
UIScreen.main.bounds.width Is deprecated. (main is deprecated) how can i solve?
thank you
Add the .frame()
modifier to your button in your view and let it occupy the screen width infinitely
var body: some View {
YourButtonClass()
.frame(maxWidth: .infinity)
}
Here's documentation on the frame modifier