반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
Tags
- 다크모드
- remote config
- swipe
- gcd
- Android
- 문자열
- github
- Observable
- SwiftUI
- string
- Alamofire
- autolayout
- 웹뷰
- SwiftLint
- Apple
- 라이트모드
- Firebase
- Realtime Database
- Java
- LazyHStack
- NavigationLink
- WebView
- UIButton
- UIScrollView
- ios
- UITabBarController
- dictionary
- Swift
- subscript
- RxSwift
Archives
- Today
- Total
점진적 과부하 개발 블로그
Swift UISearchController 본문
반응형
Swift UISearchController 정리
UISearchController란?
- 검색창을 유저가 선택되었을 때 캔슬이나 모든 동작을 핸들링 할수 있는 집약체
UISearchBar
- UISearchController에 있는 검색창 모양의 입력값만 받는 UIComponent
NavigationBar에 SearchBar 구현해보기
private func setNavigationItems() {
navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.title = "지하철 도착 정보"
let searchController = UISearchController()
searchController.searchBar.placeholder = "지하철 역을 입력해주세요."
searchController.obscuresBackgroundDuringPresentation = false // SearchBar가 선택이 되었을 때 배경을 흐리게 해줌
searchController.searchBar.delegate = self
navigationItem.searchController = searchController
}
UISearchBarDelegate 프로토콜
extension StationSearchViewController: UISearchBarDelegate { // 특정 행동의 동작을 위임해주는 프로토콜
func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) { // 유저가 수정을 시작했을 때 불려짐
}
func searchBarTextDidEndEditing(_ searchBar: UISearchBar) { // 유저가 수정을 마쳤을 때 불려짐
}
}
실행 화면
반응형
'Swift' 카테고리의 다른 글
Swift 인스타그램 앱 클론 코딩(1) (0) | 2022.05.02 |
---|---|
Swift UIRefreshControl (0) | 2022.05.01 |
Swift UIActivityViewController 파일 공유 (0) | 2022.04.26 |
Swift 서브스크립트(Subscript) (0) | 2022.04.24 |
Swift plist 불러오기 (0) | 2022.04.23 |