Reputation: 9925
How to declare Button struct to display multiline strings?
import SwiftUI
struct ContentView : View {
var body: some View {
return Button("Line 1 \n Line 2") {}
}
}
Upvotes: 6
Views: 4684
Reputation: 6213
If you want multiline Button
then you can implement it like this.
Button(action: {
print("Action goes here")
}, label: {
Text("Line 1 \n Line 2").lineLimit(nil)
})
Upvotes: 3
Reputation: 15758
You can use Button
method lineLimit(_:)
struct ContentView : View {
var body: some View {
Button("Hello World").lineLimit(nil)
}
}
Upvotes: 4