CardAnimation
  • February 29, 2024

Design from Dribble.

实现思路在这里

Two Solutions


At the begin, I didn’t encapsulate code, @luxorules refactor code into class and improve it to support not only image, then I encapsulate my code into class. So, there are two choices.

CardContainerView by seedante

 

Here is CardContainerView API referenceCardContainerView supports custom card size, pan gesture.

Example:

let cardContainerView = CardContainerView(frame: aFrame)// with defalut card size.
cardContainerView.dataSource = id<CardContainerDataSource>

Done.

public protocol CardContainerDataSource: class{
func numberOfCards(for cardContainerView: UICardContainerView) -> Int
func cardContainerView(_ cardContainerView: UICardContainerView, imageForCardAt index: Int) -> UIImage?
}

CardAnimationView by @luxorules

 

CardAnimationView supports custom card size, pan gesture.

Usage is simple also:

let cardAnimationView = CardAnimationView.init(frame: aFrame)// with defalut card size.
cardAnimationView.dataSourceDelegate = id<CardAnimationViewDataSource>

It adds a little complexity to exchange for: custom card view(not only image).

protocol CardAnimationViewDataSource : class {
func numberOfVisibleCards() -> Int
func numberOfCards() -> Int
// Return view displayed in the CardAnimationView. If reusedView is not nil,
// you could configure and return it to reuse it.
func cardNumber(number:Int, reusedView:BaseCardView?) -> BaseCardView
}

Classes:

  • CardAnimationView: UIView, the view to display a list of card view.
  • BasedCardView: UIView, all custom card view must be inherited from this class.
  • ImageCardView: BasedCardView, child class of BasedCardView, if you just want to use image, use this class.

Requirements


  • iOS 8.0/Swift 4.0

GitHub


View Github

#card #ios8 #swift
YOU MIGHT ALSO LIKE...
CameraBackground

Features Both front and back camera supported. Flash modes: auto, on, off. Countdown timer. Tap to focus. Pinch to zoom. Usage  

DKCamera

Description A light weight & simple & easy camera for iOS by Swift. It uses CoreMotion framework to detect device orientation, so ...

HorizonSDK-iOS

Horizon SDK is a state of the art real-time video recording / photo shooting iOS library. Some of the features ...

LLSimpleCamera

LLSimpleCamera: A simple customizable camera - video recorder control LLSimpleCamera is a library for creating a customized camera - video ...

RSBarcodes_Swift

RSBarcodes allows you to read 1D and 2D barcodes using the metadata scanning capabilities introduced with iOS 7 and generate ...