action sheet 사용하기
action sheet = 아래에서 튀어나오는 메뉴. 보통 프로필이미지 지정 옵션을 줄때 사용.
//action sheet title 지정
let optionMenu = UIAlertController(title: nil, message: "Choose Option", preferredStyle: .actionSheet)
//옵션 초기화
let deleteAction = UIAlertAction(title: "Delete", style: .default, handler: {
(alert: UIAlertAction!) -> Void in
})
let saveAction = UIAlertAction(title: "Save", style: .default, handler: {
(alert: UIAlertAction!) -> Void in
})
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: {
(alert: UIAlertAction!) -> Void in
})
//action sheet에 옵션 추가.
optionMenu.addAction(deleteAction)
optionMenu.addAction(saveAction)
optionMenu.addAction(cancelAction)
//show
self.present(optionMenu, animated: true, completion: nil)
delete, save, cancle등 원하는 옵션을 넣어서 초기화되면 된다. 원래는 actionsheet라는 클래스가 있었지만
이제는 UIalertontroller로 대체!
'swift 개발' 카테고리의 다른 글
[swift] swift #selector를 변수로사용하기. (0) | 2017.09.04 |
---|---|
[swift] autolayout을 이용한 채팅창 메시지 UI구현 (0) | 2017.08.21 |
[swift] IBDesignable class 만들기 (0) | 2017.08.18 |
[ swift ] 카카오스토리 공유하기. (0) | 2017.07.10 |
[swift] dynamic tableview cell height, uitableview 다른크기의 셀높이 지정하기. (0) | 2017.07.05 |
WRITTEN BY
- arcjeen
ios 관련문의 slimforce@naver.com