Dropdown with custom view swift || dropdown option with customcell in swift
Solution:
{
let dropDown = DropDown()
var control:UIView! = btn.plainView
var items:[String] = []
for value in values {
let name = value["name"]
items.append("\(name)"
}
dropDown.anchorView = sender != nil ? sender : control // UIView or UIBarButtonItem
dropDown.selectionBackgroundCo
dropDown.direction = .any
dropDown.dataSource = items
dropDown.cellHeight = 60
dropDown.separatorColor = .gray
dropDown.cellNib = UINib(nibName: "Cell", bundle: nil)
dropDown.customCellConfigurati
guard let cell = cell as? Cell else { return }
cell.optionLabel.text = item
// Setup your custom UI components
}
dropDown.selectionAction = { [unowned viewControl] (index: Int, item: String) in
// Setup your after selection code here
}
dropDown.show()
}
The above are the code for showing dropdown with custom cell
Below code is that for the cell configuration
import UIKit
import DropDown
class Cell: DropDownCell {
@IBOutlet weak var nameBtn: UIButton!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
Comments
Post a Comment