티스토리 뷰
728x90
반응형
UITextField 에 입력시 키보드 위 toolbar 구현
미리 알림에서 UITextField 에 입력을 할 때 키보드 위 toolbar 를 구현하려고 한다.

계획
UIToolbar 객체를 만들어서 textField 가 first responder 될 때 즉 focus 될 때 receiver 에 accessory view 를 보이게 할 것이다.
inputAccessoryView
이 속성은 일반적으로 UITextField, UITextView 의 시스템제공 키보드에 악세사리 뷰를 연결하는데 사용. first responder 될 때 즉, focus 될 때 악세사리 뷰를 보여줄 수 있다.
//set UIToolbar
private func setToolbar() -> UIToolbar {
let toolbar = UIToolbar()
//resize
toolbar.sizeToFit()
let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil)
let calendarBarBtn = UIBarButtonItem(image: UIImage(systemName: "calendar.badge.clock"), style: .plain, target: self, action: nil)
let locationBarBtn = UIBarButtonItem(image: UIImage(systemName: "location"), style: .plain, target: self, action: nil)
let flagBarBtn = UIBarButtonItem(image: UIImage(systemName: "flag"), style: .plain, target: self, action: nil)
flagBarBtn.isEnabled = false
let cameraBarBtn = UIBarButtonItem(image: UIImage(systemName: "camera"), style: .plain, target: self, action: nil)
cameraBarBtn.isEnabled = false
toolbar.items = [calendarBarBtn, flexibleSpace, locationBarBtn, flexibleSpace, flagBarBtn, flexibleSpace, cameraBarBtn]
return toolbar
}
//inputAccessoryView
reminderField.inputAccessoryView = setToolbar()
결과

출처
728x90
반응형
'iOS' 카테고리의 다른 글
iOS) UINavigationBar 의 large title 색 설정 (0) | 2021.07.21 |
---|---|
iOS) push 와 pop 시 ViewLifeCycle (0) | 2021.07.21 |
iOS) UITalbeView editing mode 에서 multiple selection 구현 (0) | 2021.07.21 |
iOS) UITalbeViewCell SwipeAction (0) | 2021.07.21 |
iOS) UITalbeView Separator 없애기 (0) | 2021.07.20 |
댓글
TAG
- watchOS
- 서버통신
- MVVM
- UserDefaults
- WWDC22
- YPImagePicker
- WidgetKit
- configurable widget
- CloneCoding
- rxswift
- APNS
- Protocol
- Swift
- MOYA
- RxCocoa
- OpenSourceLibrary
- containerBackground
- Notification
- WWDC
- Firebase
- Objective-C
- IOS
- 2022 KAKAO TECH INTERNSHIP
- Widget
- urlsession
- async/await
- projectsetting
- Algorithm
- github
- SwiftUI
최근에 올라온 글
최근에 달린 댓글
글 보관함
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
링크
- Total
- Today
- Yesterday