CardContainerView
open class CardContainerView: UIView
A view to display images like cards, support pan gesture to slide up and down. Its prototype: https://cdn.dribbble.com/users/32399/screenshots/1265487/like-dribbble-video_2x.gif
-
A Boolean value deciding whether control brightness on different cards. The default value is true.
Declaration
Swift
public var enableBrightnessControl: Bool = true
-
The max number of visible cards in the view. The default value is 10.
Declaration
Swift
public var maxVisibleCardCount: Int = 10
-
A Boolean value deciding whether provide a border on every card view. The default value is true.
Declaration
Swift
public var needsBorder: Bool = true
-
The size of the first card you see. If you change this value, call
layoutCardsIfNeeded()
to resize cards. The default value is (400, 300).Declaration
Swift
public var cardSize = CGSize(width: 400, height: 300)
-
Color of card’s back. If it’s nil, card back is black. The default value is nil.
Declaration
Swift
public var cardBackColor: UIColor?
-
The border width of the first card you see. The default value is 5.
Declaration
Swift
public var cardBorderWidth: CGFloat = 5
-
Specify max distance(points) between cards in vertical direction. The default value is 35.
Declaration
Swift
public var maxYOffsetBetweenCards: CGFloat = 35
-
Specify min distance(points) between cards in vertical direction. The default value is 15.
Declaration
Swift
public var minYOffsetBetweenCards: CGFloat = 15
-
The data source must adopt the CardContainerDataSource protocol. The data source is not retained.
Declaration
Swift
public weak var dataSource: CardContainerDataSource?
-
Head card’s location in data source. If data source is nil or empty, returns nil. Specially, if cards slide to end, it returns card count.
Declaration
Swift
public var headCardIndexAtDataSource: Int?
-
Init a CardContainerView with specified frame and default card size.
Declaration
Swift
public override init(frame: CGRect)
Parameters
frame
The frame rectangle for the view.
-
Init a CardContainerView with specified frame and card size.
Declaration
Swift
public init(frame: CGRect, cardSize: CGSize = CGSize(width: 400, height: 300))
Parameters
frame
The frame rectangle for the view.
cardSize
The card size. The default value is (400, 300)
-
Init from storyboard/xib file. Card size is default value: (400, 300).
Declaration
Swift
required public init?(coder aDecoder: NSCoder)
-
Slide down the head card. This method is safe.
Declaration
Swift
public func slideDown()
-
Slide up a card to be the head card. The method is safe.
Declaration
Swift
public func slideUp()
-
Insert a cark at specified location. You must update data source before calling this method. And you must call this method after updating data source.
If location is not visible, no animation.
Declaration
Swift
public func insertCard(at index: Int)
Parameters
index
Card index in the data source.
-
Remove card at specified location. You muust update data source before calling this method. And you must call this method after updating data source.
If location is not visible, no animation.
Declaration
Swift
public func removeCard(at index: Int)
Parameters
index
Card index in the data source.
-
Lay out all cards immediately. If you change
cardSize
, call this method to resize cards.Declaration
Swift
public func layoutCardsIfNeeded()