모바일/IOS

UIAlertController, UIAlertAction

죠부니 2018. 2. 9. 15:36
반응형

        //1. 알람창 형식 정의

        let alert = UIAlertController(title: "로그인", message: "로그인 하시겠습니까?", preferredStyle: .alert)

        //2. 버튼정의

        let okAction = UIAlertAction(title: "확인", style: .default, handler: {(UIAlertAction) in

            

        })

        let cancelAction = UIAlertAction(title: "취소", style: .cancel)

        

        //3. 버튼을 알림창 객체에 추가

        alert.addAction(okAction)

        alert.addAction(cancelAction)

        

        self.present(alert,animated: true)



액션시트부분

        let alert = UIAlertController(title: "이메일 도메인 선택", message: "이메일 도메인을 선택하세요", preferredStyle: .actionSheet)

        for i in ["naver.com", "gmail.com", "hanmail.net", "nate.com", "daum.net", "hotmail.com", "lycos.co.kr", "korea.com", "dreamwiz.com", "yahoo.com", "ymail.com", "live.com", "msn.com", "me.com", "icloud.com", "rocketmail.com", "qq.com", "link.com"] {

            alert.addAction(UIAlertAction(title: i, style: .default, handler: setEmailTextField))

        }

        

        

        let cancelAction = UIAlertAction(title: "닫기", style: .cancel)

        alert.addAction(cancelAction)

        self.present(alert,animated: true)


반응형