CreationKit Documentation

Class Scrollable​Stack

public class ScrollableStack: UIScrollView  
ScrollableStack ScrollableStack UIScrollView UIScrollView ScrollableStack->UIScrollView

Nested Types

ScrollableStack.Cell

A view that wraps every row in a ScrollableStack

ScrollableStack.Errors

Conforms To

UIScrollView

Initializers

init()

public init()  

Properties

axis

public var axis: NSLayoutConstraint.Axis  

The direction that rows are laid out in the stack view.

If axis is .vertical, rows will be laid out in a vertical column. If axis is .horizontal, rows will be laid out horizontally, side-by-side.

This property also controls the direction of scrolling in the stack view. If axis is .vertical, the stack view will scroll vertically, and rows will stretch to fill the width of the stack view. If axis is .horizontal, the stack view will scroll horizontally, and rows will be sized to fill the height of the stack view.

The default value is .vertical.

row​Count

public var rowCount: Int  

The amount of rows in the stack view.

first​Row

public var firstRow: UIView?  

The first row in the stack view.

This property is nil if there are no rows in the stack view.

last​Row

public var lastRow: UIView?  

The last row in the stack view.

This property is nil if there are no rows in the stack view.

row​Inset

public var rowInset  

Specifies the default inset of rows.

This inset will be used for any new row that is added to the stack view.

You can use this property to add space between a row and the left and right edges of the stack view and the rows above and below it. Positive inset values move the row inward and away from the stack view edges and away from rows above and below.

The default inset is 0pt all around.

row​Background​Color

public var rowBackgroundColor = UIColor.clear

The background color of rows in the stack view.

This background color will be used for any new row that is added to the stack view. The default color is clear.

row​Highlight​Color

public var rowHighlightColor = ScrollableStack.defaultRowHighlightColor

The highlight background color of rows in the stack view.

This highlight background color will be used for any new row that is added to the stack view. The default color is #D9D9D9 (RGB 217, 217, 217).

automatically​Hides​Last​Separator

public var automaticallyHidesLastSeparator = true  

Automatically hides the separator of the last cell in the stack view.

Default is true.

hides​Separators​ByDefault

public var hidesSeparatorsByDefault = true

Specifies the default visibility of row separators.

When true, separators will be hidden for any new rows added to the stack view. When false, separators will be visible for any new rows added. Default is true`, meaning separators are visible for any new rows that are added.

Methods

add(_:​animated:​)

func add(_ row: UIView, animated: Bool = false)  

Adds a row to the end of the stack view.

If animated is true, the insertion is animated.

add(_:​animated:​)

func add(_ rows: [UIView], animated: Bool = false)  

Adds multiple rows to the end of the stack view.

If animated is true, the insertions are animated.

prepend(_:​animated:​)

func prepend(_ row: UIView, animated: Bool = false)  

Adds a row to the beginning of the stack view.

If animated is true, the insertion is animated.

prepend(_:​animated:​)

func prepend(_ rows: [UIView], animated: Bool = false)  

Adds multiple rows to the beginning of the stack view.

If animated is true, the insertions are animated.

insert(_:​before:​animated:​)

func insert(_ row: UIView, before beforeRow: UIView, animated: Bool = false)  

Inserts a row above the specified row in the stack view.

If animated is true, the insertion is animated.

insert(_:​before:​animated:​)

func insert(_ rows: [UIView], before beforeRow: UIView, animated: Bool = false)  

Inserts multiple rows above the specified row in the stack view.

If animated is true, the insertions are animated.

insert(_:​after:​animated:​)

func insert(_ row: UIView, after afterRow: UIView, animated: Bool = false)  

Inserts a row below the specified row in the stack view.

If animated is true, the insertion is animated.

insert(_:​after:​animated:​)

func insert(_ rows: [UIView], after afterRow: UIView, animated: Bool = false)  

Inserts multiple rows below the specified row in the stack view.

If animated is true, the insertions are animated.

insert(_:​at:​animated:​)

func insert(_ row: UIView, at index: Int, animated: Bool = false)  

Inserts a new row at the specified index.

Parameters

row UIView

The row to add.

index Int

The index to place the row at.

animated Bool

If true, the insertion is animated.

remove(_:​animated:​)

func remove(_ row: UIView, animated: Bool = false)  

Removes the given row from the stack view.

If animated is true, the removal is animated.

remove(_:​animated:​)

func remove(_ rows: [UIView], animated: Bool = false)  

Removes the given rows from the stack view.

If animated is true, the removals are animated.

remove​All​Rows(keeping:​animated:​)

func removeAllRows(keeping rows: [UIView] = [], animated: Bool = false)  

Removes all the rows in the stack view.

Parameters

rows [UIView]

The rows that should be kept, if any. Defaults to an empty array.

animated Bool

If true, the removals are animated.

all​Rows()

func allRows() -> [UIView]  

Returns an array containing of all the rows in the stack view.

The rows in the returned array are in the order they appear visually in the stack view.

contains(_:​)

func contains(_ row: UIView) -> Bool  

Returns true if the given row is present in the stack view, false otherwise.

configured​Cell(for:​)

func configuredCell(for row: UIView) -> ScrollableStack.Cell?  

Returns the configured ScrollableStack.Cell for the given row.

row(at:​)

func row(at index: Int) -> UIView?  

Returns the row in the stack view at an index.

index(of:​)

func index(of row: UIView) -> Int?  

Returns the index of a row.

hide(_:​animated:​)

func hide(_ row: UIView, animated: Bool = false)  

Hides the given row, making it invisible.

If animated is true, the change is animated.

hide(_:​animated:​)

func hide(_ rows: [UIView], animated: Bool = false)  

Hides the given rows, making them invisible.

If animated is true, the changes are animated.

show(_:​animated:​)

func show(_ row: UIView, animated: Bool = false)  

Shows the given row, making it visible.

If animated is true, the change is animated.

show(_:​animated:​)

func show(_ rows: [UIView], animated: Bool = false)  

Shows the given rows, making them visible.

If animated is true, the changes are animated.

set​Row​Hidden(_:​is​Hidden:​animated:​)

func setRowHidden(_ row: UIView, isHidden: Bool, animated: Bool = false)  

Hides the given row if isHidden is true, or shows the given row if isHidden is false.

If animated is true, the change is animated.

set​Rows​Hidden(_:​is​Hidden:​animated:​)

func setRowsHidden(_ rows: [UIView], isHidden: Bool, animated: Bool = false)  

Hides the given rows if isHidden is true, or shows the given rows if isHidden is false.

If animated is true, the change are animated.

is​Row​Hidden(_:​)

func isRowHidden(_ row: UIView) -> Bool  

Returns true if the given row is hidden, false otherwise.

tapped(row:​)

func tapped<RowView: UIView>(row: RowView) -> AnyPublisher<RowView, Never>  

Creates a control event that will be invoked when the given row in the stack is tapped by the user.

The event will be passed the row.

set​Background​Color(row:​color:​)

func setBackgroundColor(row: UIView, color: UIColor)  

Sets the background color for the given row to the UIColor provided.

set​Background​Color(rows:​color:​)

func setBackgroundColor(rows: [UIView], color: UIColor)  

Sets the background color for the given rows to the UIColor provided.

set​Inset(row:​inset:​)

func setInset(row: UIView, inset: UIEdgeInsets)  

Sets the inset for the given row to the UIEdgeInsets provided.

set​Inset(rows:​inset:​)

func setInset(rows: [UIView], inset: UIEdgeInsets)  

Sets the inset for the given rows to the UIEdgeInsets provided.

set​Separator​Inset(row:​inset:​)

func setSeparatorInset(row: UIView, inset: UIEdgeInsets)  

Sets the separator inset for the given row to the UIEdgeInsets provided.

Only left and right insets are honored.

set​Separator​Inset(rows:​inset:​)

func setSeparatorInset(rows: [UIView], inset: UIEdgeInsets)  

Sets the separator inset for the given rows to the UIEdgeInsets provided.

Only left and right insets are honored.

hide​Separator(row:​)

func hideSeparator(row: UIView)  

Hides the separator for the given row.

hide​Separators(rows:​)

func hideSeparators(rows: [UIView])  

Hides separators for the given rows.

show​Separator(row:​)

func showSeparator(row: UIView)  

Shows the separator for the given row.

show​Separators(rows:​)

func showSeparators(rows: [UIView])  

Shows separators for the given rows.

scroll​Row​ToVisible(_:​animated:​)

func scrollRowToVisible(_ row: UIView, animated: Bool = true)  

Scrolls the given row onto screen so that it is fully visible.

If animated is true, the scroll is animated. If the row is already fully visible, this method does nothing.

cell​For​Row(_:​)

func cellForRow(_ row: UIView) -> ScrollableStack.Cell  

Returns the ScrollableStack.Cell to be used for the given row.

An instance of ScrollableStack.Cell wraps every row in the stack view.

Subclasses can override this method to return a custom ScrollableStack.Cell subclass, for example to add custom behavior or functionality that is not provided by default.

If you customize the values of some properties of ScrollableStack.Cell in this method, these values may be overwritten by default values after the cell is returned. To customize the values of properties of the cell, override configureCell(_:) and perform the customization there, rather than on the cell returned from this method.

configure​Cell(_:​)

func configureCell(_ cell: ScrollableStack.Cell)  

Allows subclasses to configure the properties of the given ScrollableStack.Cell.

This method is called for newly created cells after the default values of any properties of the cell have been set by the superclass.

The default implementation of this method does nothing.