Search Components

Input

Two search components: TTBaseSearchBar — a styled UISearchBar without background artifacts, and TTBaseSearchView — a composite view combining a AwesomePro search icon + TTBaseUITextField with a real-time change handler.

ClassBaseUse Case
TTBaseSearchBarUISearchBarNative search bar with clean TTBaseUIKit styling
TTBaseSearchViewTTBaseUIViewCustom icon+textfield search row with change callback

// Simple search bar
let searchBar = TTBaseSearchBar(withType: .DEF, textPlaceHolder: "Search products...")
searchBar.delegate = self

// Embed in navigation bar
navigationItem.searchController = UISearchController(searchResultsController: nil)
navigationItem.searchController?.searchBar.placeholder = "Search"

// Get underlying text field for advanced styling
let tf = searchBar.getTextField()
tf?.font = UIFont.systemFont(ofSize: 15)

🔎 TTBaseSearchView

// Default search view with icon + text field
let searchView = TTBaseSearchView()

// With placeholder and custom icon color
let searchView = TTBaseSearchView(
    withIconColor: .systemBlue,
    searchPlaceholder: "Search by name..."
)

// Real-time text change handler
searchView.didChangeTextSearchHandle = { [weak self] text in
    self?.viewModel.filter(by: text)
}

// Add to view hierarchy
view.addSubview(searchView)
searchView.setLeadingAnchor(constant: 16)
    .setTrailingAnchor(constant: 16)
    .setTopAnchorWithAboveView(nextToView: titleLabel, constant: 12)
    .setHeightAnchor(constant: TTSize.H_TEXTFIELD + TTSize.P_CONS_DEF * 2)

📖 API Reference

TTBaseSearchView

MemberTypeDescription
iconTTBaseUIImageFontViewAwesomePro search icon (left side)
textFieldTTBaseUITextFieldInput field (NO_BORDER type)
lineViewTTLineViewOptional bottom border line
didChangeTextSearchHandle(String) → VoidCalled on every keystroke
Pro Tip: Prefer TTBaseSearchView over TTBaseSearchBar when you need pixel-perfect control over the search row layout. It's fully constraint-based and embeds cleanly inside panels, table headers, or custom nav bars.