TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jan 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Emre Duman.
Customizable dropdown list for iOS. Written in swift3.
Drag TDDropdownList.swift
file into your project structure
import UIKit
import TDDropdownList
class ViewController: UIViewController , TDDropdownListDelegate {
let list = TDDropdownList(frame: CGRect(x:60 , y : 100 , width: 200 , height: 50))
override func viewDidLoad() {
list.initialize(data: ["Github","Theduman","Dropdown","List"])
list.delegate = self
self.view.addSubview(list)
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func listTapped(sender: UIButton) {
let alert = UIAlertController(title: "TDDropdownList" ,message: "Selected item: \(sender.currentTitle!)", preferredStyle:.alert)
alert.addAction(UIAlertAction(title:"OK", style: .default, handler:nil))
self.present(alert, animated: true, completion: nil)
}
}
You need to conform TDDropdownListDelegate to get the selected item of dropdown list.
Pass the string array to initialize()
function that you want to show.
initialize(data: [String],selectedItemColor: UIColor = UIColor(red:0.74, green:0.03, blue:0.11, alpha:1.00),itemColor:UIColor = UIColor(red:0.03, green:0.30, blue:0.53, alpha:1.00),textColor: UIColor = .white,selectedItemPlaceholder:String = "\u{02304}" , animationTimer: Double = 0.5)
In the initialize()
function you can customize the UI of the library.
You can;
selectedItemColor: UIColor
parameteritemColor:UIColor
parametertextColor: UIColor
selectedItemPlaceholder:String
.You can also provide Unicode characters.animationTimer: Double
parameter