let alertController = UIAlertController(title: nil, message: "Takes the appearance of the bottom bar if specified; otherwise, same as UIActionSheetStyleDefault.", preferredStyle: .ActionSheet)
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) in
// ...
}
alertController.addAction(cancelAction)
let OKAction = UIAlertAction(title: "OK", style: .Default) { (action) in
// ...
}
alertController.addAction(OKAction)
let destroyAction = UIAlertAction(title: "Destroy", style: .Destructive) { (action) in
println(action)
}
alertController.addAction(destroyAction)
self.presentViewController(alertController, animated: true) {
// ...
}
위에꺼 이용하거나,
snippet에 등록해놓은 'alert ()' 관련에다가 여러개 붙여 쓰면 그게 액션시트가 됨
alert () 관련 코드 :
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
let cancel = UIAlertAction(title: "취소", style: .cancel)
let ok = UIAlertAction(title: buttonTitle, style: .default, handler: buttonAction)
alert.addAction(cancel)
alert.addAction(ok)
self.present(alert, animated: true)
'iOS > iOS Swift 개발 일기' 카테고리의 다른 글
[iOS swift] call by reference 참조타입(클래스) (0) | 2022.08.27 |
---|---|
데이터베이스 CRUD (0) | 2022.08.23 |
[iOS swift UIKit] UIView 배경색 랜덤으로 변경하기 (0) | 2022.07.21 |
expected declaration 오류 뜰 때 (0) | 2022.07.21 |
iOS swift 반환타입 알아내기 (0) | 2022.07.16 |