- button 클릭 시 alert 띄우기
@IBAction func Hello(_ sender: Any){
//제목은 Hello 내용은 My...인 alert 창 생성
let alert = UIAlertController(title: "Hello", message: "My First App project F!!"
,preferredStyle:.alert)
// alert 창 아래 OK title을 가진 action 버튼이 생성됨
//, handler: nil 일시 클릭해도 아무일도 일어나지 않음
let action = UIAlertAction(title:"OK", style:.default, handler: nil)
// alert창에 action을 붙여줌
alert.addAction(action)
present(alert, animated: true, completion: nil)
}
- 결과화면
'Swift' 카테고리의 다른 글
[Swift] var 와 let , method , 타입추론 (0) | 2022.02.10 |
---|---|
[Swift] 로딩페이지 띄우기, pageViewController (0) | 2021.03.25 |
[Swift] Object와 문자열 (0) | 2021.03.25 |
[Swift] ViewController와 button Event (0) | 2021.03.25 |
[Swift] xcode 프로젝트 생성 (0) | 2021.03.25 |