Building Spotify App in Swift 5 & UIKit - Part 14 - Search UI (Xcode 12, 2021, Swift 5) - App
UISearchController
를 뷰 컨트롤러에 추가하기 let searchController: UISearchController = {
let results = UIViewController()
let vc = UISearchController(searchResultsController: results)
vc.searchBar.placeholder = "Songs, Artists, Albums"
vc.searchBar.searchBarStyle = .minimal
vc.definesPresentationContext = true
return vc
}()
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: GenreCollectionViewCell.identifier, for: indexPath) as? GenreCollectionViewCell else {
return UICollectionViewCell()
}
cell.configure(with: "Rock")
return cell
}
configure
을 통해 각 셀의 내용 커스텀 가능UICollectionViewCompositionalLayout
을 통해 각 컬렉션 뷰의 아이템, 그룹, 섹션의 패딩 및 너비 등을 조정 가능