TMBarLayout

open class TMBarLayout : TMBarViewFocusProvider, TMTransitionStyleable

TMBarLayout dictates the way that BarButtons are displayed within a bar, handling layout and population.

Attention: You should not directly use BarLayout, but instead inherit from it or use an available subclass such as TMHorizontalBarLayout.

  • How to display the contents of the layout.

    • .intrinsic: The layout and contents will be intrinsically sized, taking up as much space as required.
    • .fit: The layout and it’s contents will be restricted to fitting within the bounds of the bar.
    Declaration

    Swift

    public enum ContentMode
  • How to align the layout in the parent.

    • .leading: The layout will be aligned from the leading edge of the parent.
    • .center: The layout will be aligned from the center of the parent.
    • .centerDistributed: The layout will be aligned so that its entire contents is centered in the parent if possible.
    • .trailing: The layout will be aligned from the trailing edge of the parent.
    Declaration

    Swift

    public enum Alignment
  • Container view which contains actual contents

    Declaration

    Swift

    public let view: UIView
  • The content mode in which to display the content in the layout.

    Options:

    • .intrinsic: The layout and contents will be intrinsically sized, taking up as much space as required.
    • .fit: The layout and it’s contents will be restricted to fitting within the bounds of the bar.

    By default this is set to .intrinsic

    Declaration

    Swift

    public var contentMode: ContentMode { get set }
  • Inset to apply to the outside of the layout.

    Declaration

    Swift

    open var contentInset: UIEdgeInsets { get set }
  • Transition style for updating layout parameters, such as scroll offset.

    Declaration

    Swift

    public var transitionStyle: TMTransitionStyle { get set }
  • How to align the layout in the bar.

    Options:

    • .leading: The layout will be aligned from the leading edge of the parent.
    • .center: The layout will be aligned from the center of the parent.
    • .trailing: The layout will be aligned from the trailing edge of the parent.
    Declaration

    Swift

    public var alignment: Alignment { get set }
  • Layout the BarLayout.

    Declaration

    Swift

    open func layout(in view: UIView)
    Parameters
    view

    The view to use as the root of the layout.

  • Insert new bar buttons into the layout from a specified index.

    Declaration

    Swift

    open func insert(buttons: [TMBarButton], at index: Int)
    Parameters
    buttons

    The buttons to insert.

    index

    The index to start inserting the buttons at.

  • Remove existing bar buttons from the layout.

    Declaration

    Swift

    open func remove(buttons: [TMBarButton])
    Parameters
    buttons

    The buttons to remove.

  • Calculate the focusRect for the current position and capacity.

    This rect defines the area of the layout that should currently be highlighted for the selected bar button.

    Declaration

    Swift

    open func focusArea(for position: CGFloat, capacity: Int) -> CGRect
    Parameters
    position

    Current position to display.

    capacity

    Capacity of the bar (items).

    Return Value

    Calculated focus rect.

  • Inform that the layout requires a reload of its contents.

    Note

    This will only be applied if the layout has previously had content provided.
    Declaration

    Swift

    open func setNeedsReload()
  • Layout that won’t display any visible bar buttons.

    The indicator will be visible and equally distributed in the layout width.

    Declaration

    Swift

    public final class None : TMBarLayout