InputBarAccessoryView

open class InputBarAccessoryView : UIView

A powerful InputAccessoryView ideal for messaging applications

Properties

  • A delegate to broadcast notifications from the InputBarAccessoryView

    Declaration

    Swift

    open weak var delegate: InputBarAccessoryViewDelegate?
  • The background UIView anchored to the bottom, left, and right of the InputBarAccessoryView with a top anchor equal to the bottom of the top InputStackView

    Declaration

    Swift

    open var backgroundView: UIView
  • A content UIView that holds the left/right/bottom InputStackViews and the middleContentView. Anchored to the bottom of the topStackView and inset by the padding UIEdgeInsets

    Declaration

    Swift

    open var contentView: UIView
  • A UIVisualEffectView that adds a blur effect to make the view appear transparent.

    Important Notes

    1. The blurView is initially not added to the backgroundView to improve performance when not needed. When isTranslucent is set to TRUE for the first time the blurView is added and anchored to the backgroundViews edge anchors

    Declaration

    Swift

    open lazy var blurView: UIVisualEffectView { get set }
  • Determines if the InputBarAccessoryView should have a translucent effect

    Declaration

    Swift

    open var isTranslucent: Bool { get set }
  • A SeparatorLine that is anchored at the top of the InputBarAccessoryView

    Declaration

    Swift

    public let separatorLine: <<error type>>
  • The InputStackView at the InputStackView.top position

    Important Notes

    1. It’s axis is initially set to .vertical
    2. It’s alignment is initially set to .fill

    Declaration

    Swift

    public let topStackView: InputStackView
  • The InputStackView at the InputStackView.left position

    Important Notes

    1. It’s axis is initially set to .horizontal

    Declaration

    Swift

    public let leftStackView: <<error type>>
  • The InputStackView at the InputStackView.right position

    Important Notes

    1. It’s axis is initially set to .horizontal

    Declaration

    Swift

    public let rightStackView: <<error type>>
  • The InputStackView at the InputStackView.bottom position

    Important Notes

    1. It’s axis is initially set to .horizontal
    2. It’s spacing is initially set to 15

    Declaration

    Swift

    public let bottomStackView: <<error type>>
  • The main view component of the InputBarAccessoryView

    The default value is the InputTextView.

    Important Notes

    1. This view should self-size with constraints or an intrinsicContentSize to auto-size the InputBarAccessoryView
    2. Override with setMiddleContentView(view: UIView?, animated: Bool)

    Declaration

    Swift

    public private(set) weak var middleContentView: UIView? { get }
  • The InputTextView a user can input a message in

    Declaration

    Swift

    open lazy var inputTextView: InputTextView { get set }
  • A InputBarButtonItem used as the send button and initially placed in the rightStackView

    Declaration

    Swift

    open var sendButton: InputBarSendButton
  • The anchor contants used to add horizontal inset from the InputBarAccessoryView and the window. By default, an inputAccessoryView spans the entire width of the UIWindow. You can manage these insets if you wish to implement designs that do not have the bar spanning the entire width.

    Important Notes

    USE AT YOUR OWN RISK

    H:|-(frameInsets.left)-[InputBarAccessoryView]-(frameInsets.right)-|
    

    Declaration

    Swift

    open var frameInsets: HorizontalEdgePadding { get set }
  • The anchor constants used by the InputStackView’s and InputTextView to create padding within the InputBarAccessoryView

    Important Notes

    V:|...[InputStackView.top]-(padding.top)-[contentView]-(padding.bottom)-|
    
    H:|-(frameInsets.left)-(padding.left)-[contentView]-(padding.right)-(frameInsets.right)-|
    

    Declaration

    Swift

    open var padding: UIEdgeInsets { get set }
  • The anchor constants used by the top InputStackView

    Important Notes

    1. The topStackViewPadding.bottom property is not used. Use padding.top
    V:|-(topStackViewPadding.top)-[InputStackView.top]-(padding.top)-[middleContentView]-...|
    
    H:|-(frameInsets.left)-(topStackViewPadding.left)-[InputStackView.top]-(topStackViewPadding.right)-(frameInsets.right)-|
    

    Declaration

    Swift

    open var topStackViewPadding: UIEdgeInsets { get set }
  • The anchor constants used by the middleContentView

    V:|...-(padding.top)-(middleContentViewPadding.top)-[middleContentView]-(middleContentViewPadding.bottom)-[InputStackView.bottom]-...|
    
    H:|...-[InputStackView.left]-(middleContentViewPadding.left)-[middleContentView]-(middleContentViewPadding.right)-[InputStackView.right]-...|
    

    Declaration

    Swift

    open var middleContentViewPadding: UIEdgeInsets { get set }
  • Returns the most recent size calculated by calculateIntrinsicContentSize()

    Declaration

    Swift

    open override var intrinsicContentSize: CGSize { get }
  • The intrinsicContentSize can change a lot so the delegate method inputBar(self, didChangeIntrinsicContentTo: size) only needs to be called when it’s different

    Declaration

    Swift

    public private(set) var previousIntrinsicContentSize: CGSize? { get }
  • A boolean that indicates if the maxTextViewHeight has been met. Keeping track of this improves the performance The default value is FALSE

    Declaration

    Swift

    public private(set) var isOverMaxTextViewHeight: Bool { get }
  • A boolean that when set as TRUE will always enable the InputTextView to be anchored to the height of maxTextViewHeight The default value is FALSE

    Declaration

    Swift

    public private(set) var shouldForceTextViewMaxHeight: Bool { get }
  • A boolean that determines if the maxTextViewHeight should be maintained automatically. To control the maximum height of the view yourself, set this to false. The default value is TRUE

    Declaration

    Swift

    open var shouldAutoUpdateMaxTextViewHeight: Bool
  • The maximum height that the InputTextView can reach. This is set automatically when shouldAutoUpdateMaxTextViewHeight is true. To control the height yourself, make sure to set shouldAutoUpdateMaxTextViewHeight to false. The default value is 0

    Declaration

    Swift

    open var maxTextViewHeight: CGFloat { get set }
  • A boolean that determines whether the sendButton’s isEnabled state should be managed automatically. The default value is TRUE

    Declaration

    Swift

    open var shouldManageSendButtonEnabledState: Bool
  • A boolean that determines if the layout required for new or typed text should be animated. The default value is FALSE

    Declaration

    Swift

    open var shouldAnimateTextDidChangeLayout: Bool
  • The height that will fit the current text in the InputTextView based on its current bounds

    Declaration

    Swift

    public var requiredInputTextViewHeight: CGFloat { get }
  • The fixed widthAnchor constant of the leftStackView The default value is 0

    Declaration

    Swift

    public private(set) var leftStackViewWidthConstant: CGFloat { get set }
  • The fixed widthAnchor constant of the rightStackView The default value is 52

    Declaration

    Swift

    public private(set) var rightStackViewWidthConstant: CGFloat { get set }
  • Holds the InputPlugin plugins that can be used to extend the functionality of the InputBarAccessoryView

    Declaration

    Swift

    open var inputPlugins: [InputPlugin]
  • The InputBarItems held in the leftStackView

    Declaration

    Swift

    public private(set) var leftStackViewItems: [InputItem] { get }
  • The InputBarItems held in the rightStackView

    Declaration

    Swift

    public private(set) var rightStackViewItems: [InputItem] { get }
  • The InputBarItems held in the bottomStackView

    Declaration

    Swift

    public private(set) var bottomStackViewItems: [InputItem] { get }
  • The InputBarItems held in the topStackView

    Declaration

    Swift

    public private(set) var topStackViewItems: [InputItem] { get }
  • The InputBarItems held to make use of their hooks but they are not automatically added to a UIStackView

    Declaration

    Swift

    open var nonStackViewItems: [InputItem]
  • Returns a flatMap of all the items in each of the UIStackViews

    Declaration

    Swift

    public var items: [InputItem] { get }

Initialization

  • Declaration

    Swift

    public convenience init()
  • Declaration

    Swift

    public override init(frame: CGRect)
  • Declaration

    Swift

    required public init?(coder aDecoder: NSCoder)
  • Declaration

    Swift

    open override func willMove(toSuperview newSuperview: UIView?)
  • Declaration

    Swift

    open override func didMoveToWindow()

Setup

  • Sets up the default properties

    Declaration

    Swift

    open func setup()

Constraint Layout Updates

  • Invalidates the view’s intrinsic content size

    Declaration

    Swift

    open override func invalidateIntrinsicContentSize()
  • Calculates the correct intrinsicContentSize of the InputBarAccessoryView

    Declaration

    Swift

    open func calculateIntrinsicContentSize() -> CGSize

    Return Value

    The required intrinsicContentSize

  • Declaration

    Swift

    open override func layoutIfNeeded()
  • Declaration

    Swift

    open override func point(inside point: CGPoint, with event: UIEvent?) -> Bool
  • Returns the max height the InputTextView can grow to based on the UIScreen

    Declaration

    Swift

    open func calculateMaxTextViewHeight() -> CGFloat

    Return Value

    Max Height

Layout Helper Methods

  • Layout the given InputStackView’s

    Declaration

    Swift

    public func layoutStackViews(_ positions: [InputStackView.Position] = [.left, .right, .bottom, .top])

    Parameters

    positions

    The InputStackView’s to layout

  • Removes the current middleContentView and assigns a new one.

    WARNING: This will remove the InputTextView

    Declaration

    Swift

    open func setMiddleContentView(_ view: UIView?, animated: Bool)

    Parameters

    view

    New view

    animated

    If the layout should be animated

  • Removes all of the arranged subviews from the InputStackView and adds the given items. Sets the inputBarAccessoryView property of the InputBarButtonItem

    Note: If you call animated = true, the items property of the stack view items will not be updated until the views are done being animated. If you perform a check for the items after they’re set, setting animated to false will apply the body of the closure immediately.

    The send button is attached to rightStackView so remember to remove it if you’re setting it to a different stack.

    Declaration

    Swift

    open func setStackViewItems(_ items: [InputItem], forStack position: InputStackView.Position, animated: Bool)

    Parameters

    items

    New InputStackView arranged views

    position

    The targeted InputStackView

    animated

    If the layout should be animated

  • Sets the leftStackViewWidthConstant

    Declaration

    Swift

    open func setLeftStackViewWidthConstant(to newValue: CGFloat, animated: Bool, animations: (() -> Void)? = nil)

    Parameters

    newValue

    New widthAnchor constant

    animated

    If the layout should be animated

    extraAnimations

    Any extra operations that should also be animated

  • Sets the rightStackViewWidthConstant

    Declaration

    Swift

    open func setRightStackViewWidthConstant(to newValue: CGFloat, animated: Bool, animations: (() -> Void)? = nil)

    Parameters

    newValue

    New widthAnchor constant

    animated

    If the layout should be animated

    extraAnimations

    Any extra operations that should also be animated

  • Sets the shouldForceTextViewMaxHeight property

    Declaration

    Swift

    open func setShouldForceMaxTextViewHeight(to newValue: Bool, animated: Bool)

    Parameters

    newValue

    New boolean value

    animated

    If the layout should be animated

  • Calls layoutIfNeeded() on the UIInputSetContainerView that holds the InputBarAccessoryView, if it exists, else layoutIfNeeded() is called on the superview. Use this for invoking a smooth layout of a size change when used as an inputAccessoryView

    Declaration

    Swift

    public func layoutContainerViewIfNeeded()

Notifications/Hooks

  • Invalidates the intrinsicContentSize

    Declaration

    Swift

    open override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?)
  • Invalidates the intrinsicContentSize

    Declaration

    Swift

    @objc
    open func orientationDidChange()
  • Enables/Disables the sendButton based on the InputTextView’s text being empty Calls each items textViewDidChangeAction method Calls the delegates textViewTextDidChangeTo method Invalidates the intrinsicContentSize

    Declaration

    Swift

    @objc
    open func inputTextViewDidChange()
  • Calls each items keyboardEditingBeginsAction method

    Declaration

    Swift

    @objc
    open func inputTextViewDidBeginEditing()
  • Calls each items keyboardEditingEndsAction method

    Declaration

    Swift

    @objc
    open func inputTextViewDidEndEditing()

Plugins

  • Reloads each of the plugins

    Declaration

    Swift

    open func reloadPlugins()
  • Invalidates each of the plugins

    Declaration

    Swift

    open func invalidatePlugins()

User Actions

  • Calls each items keyboardSwipeGestureAction method Calls the delegates didSwipeTextViewWith method

    Declaration

    Swift

    @objc
    open func didSwipeTextView(_ gesture: UISwipeGestureRecognizer)
  • Calls the delegates didPressSendButtonWith method Assumes that the InputTextView’s text has been set to empty and calls inputTextViewDidChange() Invalidates each of the InputPlugins

    Declaration

    Swift

    open func didSelectSendButton()
  • The anchor constants used by the InputStackView

    V:|...-(padding.top)-(textViewPadding.top)-[InputTextView]-(textViewPadding.bottom)-[InputStackView.bottom]-...|
    
    H:|...-[InputStackView.left]-(textViewPadding.left)-[InputTextView]-(textViewPadding.right)-[InputStackView.right]-...|
    

    Declaration

    Swift

    @available(*, deprecated, message: "The `InputTextView` now resides in the `middleContentView` and thus this property has been renamed to `middleContentViewPadding`")
    public var textViewPadding: UIEdgeInsets { get set }