Button trong SwiftUI
Cách sử dụng Button đơn giản
Button trong SwiftUI tương tự như UIButton, ngoại trừ nó linh hoạt hơn về nội dung mà nó hiển thị và nó sử dụng một closure cho hành động của nó thay vì action cũ.
Để tạo một Button:
Button("Title") {
print("OnPress")
}
Ví dụ: bạn có thể tạo một Button hiển thị hoặc ẩn một số văn bản khi nó được chạm vào:
struct ContentView: View {
@State private...
SwiftUI
button
1611