Search Bar
Convert Search Bar component to iOS/Android code.
Last updated
Convert Search Bar component to iOS/Android code.
Last updated
//HomePageViewController.swift
import UIKit
class HomePageViewController: UIViewController {
//Connection from an Interface Builder to a UI component
@IBOutlet private weak var searchSongSearchBar: UISearchBar!
override func viewDidLoad() {
super.viewDidLoad()
setupViews()
}
}
extension HomePageViewController {
private func setupViews() {
//SearchBar properties
searchSongSearchBar.layer.cornerRadius = 10
searchSongSearchBar.layer.masksToBounds = true
searchSongSearchBar.setBackgroundImage(UIImage(), for: .any, barMetrics: .default)
searchSongSearchBar.placeholder = NSLocalizedString("search", comment: "")
if let placeholderInsidesearchSongSearchBar = searchSongSearchBar.value(forKey: "searchField") as? UITextField {
placeholderInsidesearchSongSearchBar.textColor = UIColor.flint
placeholderInsidesearchSongSearchBar.font = UIFont.textStyle
placeholderInsidesearchSongSearchBar.textAlignment = .left
}
}
} <!--activitySongList.xml-->
<SearchView
android:id="@+id/songSearchView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:iconifiedByDefault="false"
android:queryBackground="@android:color/transparent"
android:queryHint="@string/search"
android:textAlignment="textStart"
android:textColor="?attr/flint"
android:layout_marginStart="20dp"
android:layout_marginEnd="19dp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/descriptionTextView"
app:layout_constraintBottom_toTopOf="@+id/itemBackgroundView"/>