TTDropdownCustomView
InputA tappable dropdown trigger view showing a label and a chevron/arrow icon. Presents a bottom border by default. Customize the displayed label, icon, padding, and colors. Pair with a picker/action sheet to complete the dropdown UX.
🎨 Types
public enum TYPE {
case DEFAULT // Standard padding
case PADDING // Extra padding variant
}
🚀 Usage
// Basic dropdown trigger
let dropdown = TTDropdownCustomView(
withTextToDisplay: "Select Category",
icon: "iconArrowDown"
)
// Handle tap → show picker
dropdown.onTapHandler = { [weak self] in
self?.showCategoryPicker()
}
// Update label after selection
func didSelectCategory(_ category: String) {
dropdown.textLabel.setText(text: category)
}
// Subclass to customize padding
class CustomDropdown: TTDropdownCustomView {
override var padding: (CGFloat, CGFloat, CGFloat, CGFloat) {
return (20, 14, 20, 14)
}
override var bgColor: UIColor { .systemGroupedBackground }
}
// In form layout
let genderDropdown = TTDropdownCustomView(
withTextToDisplay: "Select Gender",
icon: "chevron.down"
)
formStack.addArrangedSubview(genderDropdown)
📖 API Reference
| Member | Type | Description |
|---|---|---|
textLabel | TTBaseUILabel | The display value label |
iconView | TTBaseUIImageView | Right-side arrow/chevron icon |
padding | (CGFloat, …) | Override: (lead, top, trail, bottom) |
iconSize | CGSize | Override icon dimensions |
bgColor | UIColor | Override background (default: white) |
borderColor | UIColor | Bottom line color |
heightDef | CGFloat | Minimum height (default: H_BUTTON + P_CONS_DEF) |
Pro Tip:
TTDropdownCustomView is a visual trigger only — it doesn't include a picker. Add a UITapGestureRecognizer and present an UIAlertController(style: .actionSheet) or a custom bottom sheet (TTBasePopupViewController) on tap.