A Material Design popup list with search for iOS written in Swift.
Do pod try PBPopupList in your console and run the project to try a demo.
To install CocoaPods, run sudo gem install cocoapods in your console.
PBPopupList supports Swift 4.2 since version 1.0.
Use CocoaPods.
- Add
pod 'PBPopupList', :git => 'https://github.com/Peerbits/PBPopupList.git'to your Podfile. - Install the pod(s) by running
pod install. - Add
import PBPopupListin the .swift files where you want to use it
A regular way to use PBPopupList in your project would be using Embedded Framework. There are two approaches, using source code and adding submodule.
Add source code:
- Download the latest code version.
- Unzip the download file, copy
PBPopupListfolder to your project folder
Add submodule
- In your favorite terminal,
cdinto your top-level project directory, and entering the following command:
$ git submodule add [email protected]:Peerbits/PBPopupList.gitAfter you get the source code either by adding it directly or using submodule, then do the following steps:
- Open
PBPopupListfolder, and dragPBPopupList.xcodeprojinto the file navigator of your app project, under you app project. - In Xcode, navigate to the target configuration window by clicking the blue project icon, and selecting the application target under the "Targets" heading in the sidebar.
- Open "Build Phases" panel in the tab bar at the top of the window, expend the "Target Dependencies" group and add
PBPopupList.frameworkunder PBPopupList icon in the popup window by clicking+. Similarly, you can also addPBPopupList.frameworkin "Embedded Binaries" under "General" tab.
let popupList: PBPopupList = PBPopupList(Viewcontroller: self)
let arrayVal = [1,2,3.9,4.456458,5.987,"sv","Jan","Feb","Mar",1,2,3,"😛","😍"] as [Any]
// The list of items to display. Can be changed dynamically
popupList.createTableview(arrayVal, withTitle: "Select") { (index) in
print("array value:\(arrayVal)")
print("search result is:\(arrayVal[index])")
}Optional properties:
// To customize popup according to your requirements
popupList.rowHeight = 50
popupList.searchPlaceHolder = "Search"
popupList.isSearch = true
popupList.headerColor = .brown
popupList.cellTextColor = .blue
popupList.cellBackgroundColor = .white
popupList.isMultilineModeEnabled = trueDisplay actions:
popupList.createTableview(arrayVal, withTitle: "Select") { (index) in
print("array value:\(arrayVal)")
print("search result is:\(arrayVal[index])")
}As soon as the user interact with anything else than the PBpopup List, the PBpopup List is dismissed.
You can customize these properties of the PBPopupList:
isSearch: enable search option in PBPopup List.cellTextColor: the color of the text for each cells of the PBPopup List.cellBackgroundColor: the background color of the PBPopup List.headerColor: the background color of the hedear view of PBPopup List.rowHeight: the height of the PBPopup List cells.isMultilineModeEnabled: multiline text supported in the PBPopup List cells.
You can change them through each instance of PBPopupList like this for example:
popupList.rowHeight = 50
popupList.searchPlaceHolder = "Search"
popupList.isSearch = true
popupList.headerColor = .brown
popupList.cellTextColor = .blue
popupList.cellBackgroundColor = .white
popupList.isMultilineModeEnabled = true- Xcode 8+
- Swift 3.0
- iOS 8+
This project is under MIT license. For more information, see LICENSE file.
It will be updated when necessary and fixes will be done as soon as discovered to keep it up to date.
You can find me on Twitter @peerbits.
Enjoy!

