SearchBar


super: UISearchBar (on iOS)

The SearchBar class implements a text field control for text-based searches. The control provides a text field for entering text, a search button, a bookmark button, and a cancel button. The SearchBar object does not actually perform any searches. You use the events to implement the actions when text is entered and buttons are clicked.

Events

  • Load() This event is called when the object becames available in the current runtime system.

  • WillShow() The view is about to be added to the App's views hierarchy.

  • WillHide() The view is about to be removed from the App's views hierarchy.

  • DidBeginEditing() This event is called when the user begins editing the search text.

  • DidEndEditing() This event is called when user finished editing the search text.

  • Changed(searchText: String) This event is called to notify that the user changed the search text

  • Action(action: SearchBarAction) This event is called when a button was tapped.

  • DidSelectCell(selectedScopeIndex: Int) This event is called when the scope button selection changed.

  • DidShow() The view has been added to the App's views hierarchy.

  • DidHide() The view has been removed from the App's views hierarchy.

  • Unload() This event is called when the object has been removed from the current runtime system (but not yet deallocated).

Properties

  • var searchBarStyle: SearchBarStyle A search bar style that specifies the search bar’s appearance.

  • var barStyle: BarStyle A bar style that specifies the search bar’s appearance.

  • var text: String The current or starting search text.

  • var prompt: String A single line of text displayed at the top of the search bar.

  • var placeholder: String The string that is displayed when there is no other text in the text field.

  • var showsBookmarkButton: Bool A Boolean value indicating whether the bookmark button is displayed.

  • var showsCancelButton: Bool A Boolean value indicating whether the cancel button is displayed.

  • var showsSearchResultsButton: Bool A Boolean value indicating whether the search results button is displayed.

  • var searchResultsButtonSelected: Bool A Boolean value indicating whether the search results button is selected.

  • var translucent: Bool A Boolean value that indicates whether the search bar is translucent (true) or not (false).

  • var barTintColor: Color The tint color to apply to the search bar background.

  • var autocapitalizationType: TextAutocapitalizationType The auto-capitalization style for the text object.

  • var autocorrectionType: TextAutocorrectionType The autocorrection style for the text object.

  • var spellCheckingType: TextSpellCheckingType The spell-checking style for the text object.

  • var keyboardType: KeyboardType The keyboard style associated with the text object.

  • var scopeButtonTitles: List An array of strings indicating the titles of the scope buttons.

  • var selectedScopeButtonIndex: Int The index of the selected scope button.

  • var showsScopeBar: Bool Specifies whether the scope bar is displayed.

  • var backgroundImage: Image The background image for the search bar.

  • var scopeBarBackgroundImage: Image The background image for the scope bar.

  • var searchFieldBackgroundPositionAdjustment: Offset The offset of the search text field background in the search bar.

  • var searchTextPositionAdjustment: Offset The offset of the text within the search text field background.

  • var inputAccessoryView: UIView The custom accessory view to display when the text field becomes the first responder.

Methods

  • func animate(duration: Float, delay: Float, options: AnimationOption, closure: Closure, completion: Closure) Animate changes to one or more views using the specified duration, delay, options and completion handler.

  • func setFocus() Force focus to be set to the selected control. For TextField and TextView that means force Keyboard to appear.

  • func clearFocus() Clear focus from selected control

Enumeration

SearchBarAction

  • .Bookmark
  • .Cancel
  • .ResultsList
  • .Search

SearchBarStyle

  • .Default
  • .Minimal
  • .Prominent

BarStyle

  • .Black
  • .BlackOpaque
  • .BlackTranslucent
  • .Default

TextAutocapitalizationType

  • .AllCharacters
  • .None
  • .Sentences
  • .Words

TextAutocorrectionType

  • .Default
  • .No
  • .Yes

TextSpellCheckingType

  • .Default
  • .No
  • .Yes

KeyboardType

  • .ASCIICapable
  • .Alphabet
  • .DecimalPad
  • .Default
  • .EmailAddress
  • .NamePhonePad
  • .NumberPad
  • .NumbersAndPunctuation
  • .PhonePad
  • .Twitter
  • .URL
  • .WebSearch

AnimationOption

  • .AllowAnimatedContent
  • .AllowUserInteraction
  • .Autoreverse
  • .BeginFromCurrentState
  • .CurveEaseIn
  • .CurveEaseInOut
  • .CurveEaseOut
  • .CurveLinear
  • .LayoutSubviews
  • .OverrideInheritedCurve
  • .OverrideInheritedDuration
  • .OverrideInheritedOptions
  • .Repeat
  • .ShowHideTransitionViews
  • .TransitionCrossDissolve
  • .TransitionCurlDown
  • .TransitionCurlUp
  • .TransitionFlipFromBottom
  • .TransitionFlipFromLeft
  • .TransitionFlipFromRight
  • .TransitionFlipFromTop
  • .TransitionNone