SwiftUI - Alert View

0

SwiftUI 공부

목록 보기
6/6
post-thumbnail

Alert View

  • systemAlert
  • Button().alert(isPresented:) isPresented가 true 이면, View가 보이고, 확인 등을 누르면, false로 변하고, View가 사라짐.
  • 버튼 클릭시 action을 줄 수 있음.
...
            Button("show alert ") {
                isShowAlert.toggle()
            }
            .alert(isPresented: $isShowAlert) {
                let primaryButton = Alert.Button.default(Text("done")) {
                    selectText = "done"
                }
                let secondaryButton = Alert.Button.default(Text("cancel")) {
                    selectText = "cancel"
                }
                
                return Alert(title: Text("show alert"),
                             primaryButton: primaryButton,
                             secondaryButton: secondaryButton)
            }

...
profile
IOS 개발하며 먹고사는 게으른 개발자

0개의 댓글