HFCardCollectionViewLayout
https://github.com/hfrahmann/HFCardCollectionViewLayout
The HFCardCollectionViewLayout provides a card stack layout not quite similar like the apps Reminder and Wallet.
HFCardCollectionViewLayout提供了一个卡片堆栈布局,像 apps Reminder 和 Wallet iOS原生应用程序。
Features:
主要功能
Many options, also within the InterfaceBuilder
Flip animation to have a backview
Move/Order the cards
Simple integration (only set the Layout class in the CollectionView)
Interface Builder中包含了许多options
翻转动画有一个backview
可移动的卡片视图
简单集成(只在CollectionView中设置Layout类)
Install it with cocoapods or just use the files inside the Source directory.
pod 'HFCardCollectionViewLayout'Implementation 具体集成步骤Just set HFCardCollectionViewLayout as the custom layout class in your UICollectionView.
There is also a cell class called HFCardCollectionViewCell containing rounded corners and a shadow.
But this class has no dependency on the HFCardCollectionViewLayout.
It's only there to have a cell that looks like a card.
Important: This collectionView layout does support only one section!
DelegateThese are the delegate functions of the HFCardCollectionViewLayoutDelegate inherits from UICollectionViewDelete so you don't need to connect a further delegate.
/// Asks if the card at the specific index can be revealed. /// - Parameter collectionViewLayout: The current HFCardCollectionViewLayout. /// - Parameter canRevealCardAtIndex: Index of the card. func cardCollectionViewLayout(_ collectionViewLayout: HFCardCollectionViewLayout, canRevealCardAtIndex index: Int) -> Bool /// Asks if the card at the specific index can be unrevealed. /// - Parameter collectionViewLayout: The current HFCardCollectionViewLayout. /// - Parameter canUnrevealCardAtIndex: Index of the card. func cardCollectionViewLayout(_ collectionViewLayout: HFCardCollectionViewLayout, canUnrevealCardAtIndex index: Int) -> Bool /// Feedback when the card at the given index will be revealed. /// - Parameter collectionViewLayout: The current HFCardCollectionViewLayout. /// - Parameter didRevealedCardAtIndex: Index of the card. func cardCollectionViewLayout(_ collectionViewLayout: HFCardCollectionViewLayout, willRevealCardAtIndex index: Int) /// Feedback when the card at the given index was revealed. /// - Parameter collectionViewLayout: The current HFCardCollectionViewLayout. /// - Parameter didRevealedCardAtIndex: Index of the card. func cardCollectionViewLayout(_ collectionViewLayout: HFCardCollectionViewLayout, didRevealCardAtIndex index: Int) /// Feedback when the card at the given index will be unrevealed. /// - Parameter collectionViewLayout: The current HFCardCollectionViewLayout. /// - Parameter didUnrevealedCardAtIndex: Index of the card. func cardCollectionViewLayout(_ collectionViewLayout: HFCardCollectionViewLayout, willUnrevealCardAtIndex index: Int) /// Feedback when the card at the given index was unrevealed. /// - Parameter collectionViewLayout: The current HFCardCollectionViewLayout. /// - Parameter didUnrevealedCardAtIndex: Index of the card. func cardCollectionViewLayout(_ collectionViewLayout: HFCardCollectionViewLayout, didUnrevealCardAtIndex index: Int)Options and ActionsYou also have access to the options and (some) actions at the HFCardCollectionViewLayout object in the interface builder.
These are the public variables of HFCardCollectionViewLayout.
/////////////// Public Variables /// Only cards with index equal or greater than firstMovableIndex can be moved through the collectionView. @IBInspectable var firstMovableIndex: Int = 0 /// Specifies the height that is showing the cardhead when the collectionView is showing all cards. /// The minimum value is 20. @IBInspectable var cardHeadHeight: CGFloat = 80 /// When th collectionView is showing all cards but there are not enough cards to fill the full height, /// the cardHeadHeight will be expanded to equally fill the height. @IBInspectable var cardShouldExpandHeadHeight: Bool = true /// Stretch the cards when scrolling up @IBInspectable var cardShouldStretchAtScrollTop: Bool = true /// Specifies the maximum height of the cards. /// But the height can be less if the frame size of collectionView is smaller. @IBInspectable var cardMaximumHeight: CGFloat = 0 /// Count of bottom stacked cards when a card is revealed. /// Value must be between 0 and 10 @IBInspectable var bottomNumberOfStackedCards: Int = 5 /// All bottom stacked cards are scaled to produce the 3D effect. @IBInspectable var bottomStackedCardsShouldScale: Bool = true /// Specifies the margin for the top margin of a bottom stacked card. /// Value can be between 0 and 20 @IBInspectable var bottomCardLookoutMargin: CGFloat = 10 /// An additional topspace to show the top of the collectionViews backgroundView. @IBInspectable var spaceAtTopForBackgroundView: CGFloat = 0 /// Snaps the scrollView if the contentOffset is on the 'spaceAtTopForBackgroundView' @IBInspectable var spaceAtTopShouldSnap: Bool = true /// Additional space at the bottom to expand the contentsize of the collectionView. @IBInspectable var spaceAtBottom: CGFloat = 0 /// Area the top where to autoscroll while moving a card. @IBInspectable var scrollAreaTop: CGFloat = 120 /// Area ot the bottom where to autoscroll while moving a card. @IBInspectable var scrollAreaBottom: CGFloat = 120 /// The scrollView should snap the cardhead to the top. @IBInspectable var scrollShouldSnapCardHead: Bool = false /// Cards are stopping at top while scrolling. @IBInspectable var scrollStopCardsAtTop: Bool = true /// Contains the revealed index. /// ReadOnly. private(set) var revealedIndex: Int = -1#p#分页标题#e#Interface builder actions
/////////////// InterfaceBuilder Actions /// Action for the InterfaceBuilder to flip back the revealed card. @IBAction func flipBackRevealedCardAction() /// Action for the InterfaceBuilder to unreveal the revealed card. @IBAction func unrevealRevealedCardAction()Public functions
/////////////// Public Functions /// Reveal a card at the given index. /// /// - Parameter index: The index of the card. /// - Parameter completion: An optional completion block. Will be executed the animation is finished. public func revealCardAt(index: Int, completion: (() -> Void)? = nil) /// Unreveal the revealed card /// /// - Parameter completion: An optional completion block. Will be executed the animation is finished. public func unrevealCard(completion: (() -> Void)? = nil) /// Flips the revealed card to the given view. /// The frame for the view will be the same as the cell /// /// - Parameter toView: The view for the backview of te card. /// - Parameter completion: An optional completion block. Will be executed the animation is finished. public func flipRevealedCard(toView: UIView, completion: (() -> Void)? = nil) /// Flips the flipped card back to the frontview. /// /// - Parameter completion: An optional completion block. Will be executed the animation is finished. public func flipRevealedCardBack(completion: (() -> Void)? = nil)