Search Bar

Convert Search Bar component to iOS/Android code.

A search bar allows users to search values by typing text into a field.

Component's Property info for iOS/Android

It's calledSearchBar in Swift language. It can have 2 properties on Monday Hero:

Text: The initial text displayed by the text field. You can specify the text as a plain string or as an attributed string. Placeholder: A placeholder is a text displayed by the SearchBar when the string is empty. Typing any text into the text field hides this string.

Generated iOS/Android Code

Let's see the generated code. Monday Hero will generate it even the rectangle's cornerRadius value included.

//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 
		}
	}
}	

Last updated