CreationKit Documentation

Class Card

public final class Card: UIView  

Cards contain content and tasks about a single subject to make it easier to scan, read, and take action.

Prefer to use make(header:content:footer:) rather than the default constructor.

Cards are essentially structured containers that layout a header, content, and footer. Cards also allow you to only provide specific sections, such as the header and content, without a footer for example.

Some interesting layouts include CardHeader for the header, VerticalCenteredImageTextContent for the content, and an ActionsLayout for the footer. These views will give you what CreationUI calls an Awareness Card.

Card Card UIView UIView Card->UIView

Nested Types

Card.State

The state of the card.

Conforms To

UIView

Initializers

init(header:​content:​footer:​max​Width:​)

public init(header: UIView? = nil, content: UIView? = nil, footer: UIView? = nil, maxWidth: CGFloat? = nil)  

Creates a new card. Prefer to use make(header:content:footer:) instead.

You should use this method when you have the content to display. If you need to show a loading card while you're fetching the content for the card, you should use make(with:state:) instead.

Properties

header

public private(set) var header: UIView? 

content

public private(set) var content: UIView? 

footer

public private(set) var footer: UIView? 

state

public var state: State = .normal  

The state of the card. You can use this to set as a loading state to show that you are loading the content, or an error state if the card content fails to load. Set to normal when you want to cards content to display.

Methods

make(header:​content:​footer:​max​Width:​)

public static func make(
    header: UIView? = nil, content: UIView? = nil,
    footer: UIView? = nil, maxWidth: CGFloat? = nil
  ) -> Card  

Creates a new card.

You should use this method when you have the content to display. If you need to show a loading card while you're fetching the content for the card, you should use make(with:state:) instead.

make(with:​state:​)

public static func make(with size: CGSize, state: State) -> Card  

Creates a new Card with a preferred size and state.

Note that Cards have a max width and will be clamped to that value. You should use this factory method when you don't have the content for the card yet, such as when you are loading the content, and you want to display a loading card in it's place. Then update the card when the content has been loaded. If you already have the content, then you should use init(header:,content:,footer:) instead.

insert(header:​content:​footer:​new​State:​animated:​)

public func insert(header: UIView? = nil, content: UIView? = nil,
                     footer: UIView? = nil, newState: State = .normal,
                     animated: Bool = true)  

Inserts views into the Card.

If you insert a header and the Card already has a header, the header will be replaced with the new provided header. The same occurs for the content and footer views.