1. 알람 객체 선언 및 초기화
2. 알람 버튼 만들기
3. 알람 객체와 알람 버튼 연결
4. 화면에 표현
이 순서대로 진행하면 된다.
1.
let alert = UIAlertController(title: "성공", message: "회원가입 완료!", preferredStyle: UIAlertController.Style.alert)
UIAlertController객체 생성 및 초기화.
2.
let okAction = UIAlertAction(title: "확인", style: .default) {(action) in
// 버튼을 클릭시 할 작업을 넣는다.
return
}
예를 들어 버튼을 클릭하면 메인화면을 보여주겠다 라고 할 경우
let okAction = UIAlertAction(title: "확인", style: .default) {(action) in
self.showMainController()
return
}
이렇게 추가해주면 된다.
3. 버튼과 알림창 객체를 연결시켜준다.
alert.addAction(okAction)
4.
self.present(alert, animated: true, completion: nil)
alert객체를 화면에 present 방식으로 띄워준다.