FUISearchTagsField

open class FUISearchTagsField : UIScrollView
extension FUISearchTagsField: UITextFieldDelegate
extension FUISearchTagsField: UIScrollViewDelegate

A UIScrollView shows a set of tags and a text field which allows user to input text.

Usage

Initialization

You can position tags field either setting the frame or constraints.

let tagsField = FUISearchTagsField()

Configuration

tagsField.tintColor = UIColor.preferredFioriColor(forStyle: .tintColorDark) // cursor color
tagsField.backgroundColor = UIColor.preferredFioriColor(forStyle: .primary9)
tagsField.contentInset = UIEdgeInsetsMake(9, 0, 9, 0)
tagsField.spaceBetweenTags = 5.0
tagsField.font = UIFont.systemFont(ofSize: 16)
tagsField.textColor = UIColor.preferredFioriColor(forStyle: .tintColorDark)
tagsField.fieldTextColor = UIColor.preferredFioriColor(forStyle: .tintColorDark)
tagsField.selectedColor = UIColor.preferredFioriColor(forStyle: .tintColorDark)
tagsField.selectedTextColor = UIColor.preferredFioriColor(forStyle: .primary1, background: .darkBackground)
tagsField.displayDelimiter = true
tagsField.delimiter = ","
tagsField.placeholder = "Search for Assignee"
tagsField.placeholderColor = UIColor.preferredFioriColor(forStyle: .primary3)
tagsField.numberOfLines = 2

Register a event handler

tagsField.onDidChangeText = { [weak self] (sender, text) in
// do something in response to text change.
}

Add or remove tags

tagsField.addTag("str")
tagsField.removeTag("str")

Theming

Supported class paths:

fdlFUITagsField {}

Supported TagsField attributes:

tint-color (Color) background-color (Color) content-insets (Box) font-color { -placeholder } (Color) font-name (FontName) font-style (UIFontTextStyle) font-size (Number) text-line-clamp (Integer) line-spacing (Float) tag-spacing (Float) tag-delimiter (String)

Supported Tag attributes:

tag-font-color { -selected } (Color) tag-background-color { -selected } (Color) tag-content-insets (Box)

Supported ImageView attributes:

search-icon-image (Image) search-icon-image-tint-color (Color)

  • The icon image of search image view.

    Declaration

    Swift

    open var searchIcon: UIImage? { get set }
  • An image view shows before tags in tags field.

    Declaration

    Swift

    open var searchImageView: UIImageView
  • Dedicated text field delegate.

    Declaration

    Swift

    open weak var textDelegate: UITextFieldDelegate?
  • Background color for tag view in normal (non-selected) state.

    Declaration

    Swift

    open override var tintColor: UIColor! { get set }
  • Text color for tag view in normal (non-selected) state.

    Declaration

    Swift

    open var textColor: UIColor? { get set }
  • Background color for tag view in normal(non-selected) state.

    Declaration

    Swift

    open var normalBackgroundColor: UIColor? { get set }
  • Background color for tag view in selected state.

    Declaration

    Swift

    open var selectedColor: UIColor? { get set }
  • Text color for tag view in normal (selected) state.

    Declaration

    Swift

    open var selectedTextColor: UIColor? { get set }
  • The delimiter to separate tags.

    Declaration

    Swift

    open var delimiter: String { get set }
  • A boolean value indicates if delimiter is used.

    Declaration

    Swift

    open var isDelimiterVisible: Bool { get set }
  • Max height of tags field.

    Declaration

    Swift

    open var maxHeight: CGFloat { get set }
  • Max number of lines of tags can display in FUISearchTagsField before its contents become scrollable. Default value is 0, which means FUISearchTagsField always resize to fit all tags.

    Declaration

    Swift

    open var numberOfLines: Int { get set }
  • Corner radius of tag view.

    Declaration

    Swift

    open var cornerRadius: CGFloat { get set }
  • Border width of tag view.

    Declaration

    Swift

    open var borderWidth: CGFloat { get set }
  • Border color of tags.

    Declaration

    Swift

    open var borderColor: UIColor? { get set }
  • Layout margins of tag view.

    Declaration

    Swift

    open override var layoutMargins: UIEdgeInsets { get set }
  • Text color of input text field.

    Declaration

    Swift

    open var fieldTextColor: UIColor? { get set }
  • Placeholder text.

    Declaration

    Swift

    open var placeholder: String { get set }
  • Text color of placeholder text.

    Declaration

    Swift

    open var placeholderColor: UIColor? { get set }
  • A boolean value determines if placeholder text is always visible.

    Declaration

    Swift

    open var placeholderAlwaysVisible: Bool { get set }
  • Font of text in both text field and tags.

    Declaration

    Swift

    open var font: UIFont? { get set }
  • A boolean value determines if tags field is read only or not. In read only mode, tags are not selectable and you cannot input text in text field.

    Declaration

    Swift

    open var readOnly: Bool { get set }
  • By default, the return key is used to create a tag in the field. You can change it, i.e., to use comma or space key instead.

    Declaration

    Swift

    open var acceptTagOption: FUISearchTagAcceptOption
  • Content inset of tag view.

    Declaration

    Swift

    open override var contentInset: UIEdgeInsets { get set }
  • Spacing between tags.

    Declaration

    Swift

    open var spaceBetweenTags: CGFloat { get set }
  • Space between two lines.

    Declaration

    Swift

    open var spaceBetweenLines: CGFloat { get set }
  • The layoutMargins to be applied to tag view. Default value is UIEdgeInsets.zero.

    Declaration

    Swift

    open var tagLayoutMargins: UIEdgeInsets { get set }
  • A boolean value indicating if bounce animation hanppens on selection. Default value is true.

    Declaration

    Swift

    open var bounceOnSelection: Bool
  • An array of tags in tags field.

    Declaration

    Swift

    open fileprivate(set) var tags: [FUISearchTag] { get }
  • Called when the text field should return.

    Declaration

    Swift

    open var onShouldAcceptTag: ((FUISearchTagsField) -> Bool)?
  • Called when the text field text has changed. You should update your autocompleting UI based on the text supplied.

    Declaration

    Swift

    open var onDidChangeText: ((FUISearchTagsField, _ text: String?) -> Void)?
  • Called when a tag has been added. You should use this opportunity to update your local list of selected items.

    Declaration

    Swift

    open var onDidAddTag: ((FUISearchTagsField, _ tag: FUISearchTag) -> Void)?
  • Called when a tag has been removed. You should use this opportunity to update your local list of selected items.

    Declaration

    Swift

    open var onDidRemoveTag: ((FUISearchTagsField, _ tag: FUISearchTag) -> Void)?
  • Called when a tag has been selected.

    Declaration

    Swift

    open var onDidSelectTagView: ((FUISearchTagsField, _ tag: FUISearchTagView) -> Void)?
  • Called when a tag has been unselected.

    Declaration

    Swift

    open var onDidUnselectTagView: ((FUISearchTagsField, _ tag: FUISearchTagView) -> Void)?
  • Called when the user attempts to press the Return key with text partially typed. @return A Tag for a match (typically the first item in the matching results), or nil if the text shouldn’t be accepted.

    Declaration

    Swift

    open var onVerifyTag: ((FUISearchTagsField, _ text: String) -> Bool)?
  • Called when the view has updated its own height. If you are not using Autolayout, you should use this method to update the frames to make sure the tag view still fits.

    Declaration

    Swift

    open var onDidChangeHeightTo: ((FUISearchTagsField, _ height: CGFloat) -> Void)?
  • Undocumented

    Declaration

    Swift

    open var preferredMaxLayoutWidth: CGFloat { get }
  • Undocumented

    Declaration

    Swift

    open override var intrinsicContentSize: CGSize { get }
  • Undocumented

    Declaration

    Swift

    open override func willMove(toSuperview newSuperview: UIView?)
  • Take the text inside of the field and make it a Tag.

    Declaration

    Swift

    open func acceptCurrentTextAsTag()
  • A boolean value determines if input text field is editable.

    Declaration

    Swift

    open var isEditing: Bool { get }
  • Notify tags field to begin editing.

    Declaration

    Swift

    open func beginEditing()
  • Notify tags field to end editing.

    Declaration

    Swift

    open func endEditing()
  • Add tags into tags field.

    Declaration

    Swift

    open func addTags(_ tags: [String])

    Parameters

    tags

    Initiate tags with an array of strings.

  • Add tags into tags field.

    Declaration

    Swift

    open func addTags(_ tags: [FUISearchTag])

    Parameters

    tags

    Initiate tags with an array of FUISearchTag structs.

  • Add a tag into tags field.

    Declaration

    Swift

    open func addTag(_ tag: String)

    Parameters

    tags

    Initiate a tag with a string.

  • Add a tag into tags field.

    Declaration

    Swift

    open func addTag(_ tag: FUISearchTag)

    Parameters

    tags

    Initiate a tag with a FUISearchTag struct.

  • Remove a tag from tags field.

    Declaration

    Swift

    open func removeTag(_ tag: String)

    Parameters

    tag

    The tag with specific string to be removed.

  • Remove a tag from tags field.

    Declaration

    Swift

    open func removeTag(_ tag: FUISearchTag)

    Parameters

    tag

    The tag with specific FUISearchTag struct to be removed.

  • Remove a tag at specific index from tags field.

    Declaration

    Swift

    open func removeTagAtIndex(_ index: Int)

    Parameters

    tag

    The index of the tag to be removed.

  • Remove all the tags from tags field.

    Declaration

    Swift

    open func removeTags()
  • Generate a tag with text in text field then add it to tags field.

    Declaration

    Swift

    @discardableResult
    open func tokenizeTextFieldText() -> FUISearchTag?

    Return Value

    The tag tokenized.

  • Called when text in text field changeds.

    Declaration

    Swift

    @objc
    open func onTextFieldDidChange(_ sender: AnyObject)

    Parameters

    sender

    The text field which invokes this method.

  • Select next tag.

    Declaration

    Swift

    open func selectNextTag()
  • Select previous tag.

    Declaration

    Swift

    open func selectPrevTag()
  • Select a tag view.

    Declaration

    Swift

    open func selectTagView(_ tagView: FUISearchTagView, animated: Bool = false)

    Parameters

    tagView

    The tag view to select.

    animated

    If the selection should be animated. Default value is false.

  • Unselect all the tags.

    Declaration

    Swift

    open func unselectAllTagViewsAnimated(_ animated: Bool = false)

    Parameters

    animated

    If deselection should be animated. Default value if false.

  • The set of edges of the view, which should display a separator line.

    Defaults to .none.

    Important

    Only top and bottom edges support separator lines. Options .left and .right will be ignored.
     view.separators = .top
    

    Declaration

    Swift

    open var borders: UIRectEdge { get set }
  • The keyboard type to be used with a Quartz event source.

    Declaration

    Swift

    public var keyboardType: UIKeyboardType { get set }
  • The visible title of the Return key.

    Declaration

    Swift

    public var returnKeyType: UIReturnKeyType { get set }
  • The spell-checking style for the text object.

    Declaration

    Swift

    public var spellCheckingType: UITextSpellCheckingType { get set }
  • The auto-capitalization style for the text object.

    Declaration

    Swift

    public var autocapitalizationType: UITextAutocapitalizationType { get set }
  • The autocorrection style for the text object.

    Declaration

    Swift

    public var autocorrectionType: UITextAutocorrectionType { get set }
  • A Boolean value indicating whether the Return key is automatically enabled when the user is entering text.

    Declaration

    Swift

    public var enablesReturnKeyAutomatically: Bool { get set }
  • The text of input text field.

    Declaration

    Swift

    public var text: String? { get set }
  • Undocumented

    Declaration

    Swift

    override open var inputAccessoryView: UIView? { get }
  • The custom accessory view to display when the text field becomes the first responder.

    Declaration

    Swift

    open var inputFieldAccessoryView: UIView? { get set }