Extend the width of button using swiftUI.

Solution:


struct myButton: ButtonStyle {

    func makeBody(configuration: Configuration) -> some View {
        configuration.label
            .padding()
            .frame(minWidth: 0,
                   maxWidth: .infinity)
            .foregroundColor(.white)
            .padding()
            .background( RoundedRectangle(cornerRadius: 5.0).fill(Color.orange)
        )
    }

}

Use the button be like below.


Button(action: { self.isActive = true }) {
        Text("Login")
           .fontWeight(.bold)
    }   .buttonStyle(myButton())

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift