TTDropdownCustomView

Input

A 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

MemberTypeDescription
textLabelTTBaseUILabelThe display value label
iconViewTTBaseUIImageViewRight-side arrow/chevron icon
padding(CGFloat, …)Override: (lead, top, trail, bottom)
iconSizeCGSizeOverride icon dimensions
bgColorUIColorOverride background (default: white)
borderColorUIColorBottom line color
heightDefCGFloatMinimum 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.