Skip to content

Commit 6a5d468

Browse files
committed
Update Usage.
1 parent a84e2d8 commit 6a5d468

File tree

1 file changed

+60
-2
lines changed

1 file changed

+60
-2
lines changed

README.md

+60-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,65 @@
11
# CardAnimation
2-
[Design from Dribble](https://dribbble.com/shots/1265487-First-shot-in-Chapps-Animation)[blog](http://www.jianshu.com/p/286222d4edf8) for this, only chinese.
2+
[Design from Dribble](https://dribbble.com/shots/1265487-First-shot-in-Chapps-Animation). And a [blog](http://www.jianshu.com/p/286222d4edf8) for this, only chinese.
33
![Design from Dribble](https://d13yacurqjgara.cloudfront.net/users/32399/screenshots/1265487/attachments/173545/secret-project-animation_2x.gif)
44

5+
Thanks for [@luxorules](https://github.com/luxorules/CardAnimation/tree/Component)'s great work. Now you can use this animation in your project easily.
6+
7+
Features:
8+
- Custom card View size. (New added by @luxorules)
9+
- Custom card view, not only image view. (New added by @luxorules)
10+
- Support pan gesture.
11+
12+
**How to use it in your project**
13+
14+
Drap class files in the "Classes" folder into your project, includes CardAnimationView.swift and ImageCardView.swift.
15+
16+
Classes:
17+
18+
- CardAnimationView: UIView, the view to display a list of card view.
19+
- BasedCardView: UIView, all custom card view must be inherited from this class.
20+
- ImageCardView: BasedCardView, child class of BasedCardView, if you just want to use image, use this class.
21+
22+
You can custom animation behavior by set the below properties.
23+
24+
/// Animation time for a single card animation.
25+
26+
`public var animationsSpeed = 0.2`
27+
28+
// Defines the card size that will be used. (width, height)
29+
30+
`public var cardSize : (width:CGFloat, height:CGFloat)`
31+
32+
CardAnimationView needs a data source delegate to display the content, like UICollectionView.
33+
34+
`public weak var dataSourceDelegate : CardAnimationViewDataSource?`
35+
36+
protocol CardAnimationViewDataSource : class {
37+
func numberOfVisibleCards() -> Int
38+
func numberOfCards() -> Int
39+
/**
40+
Ask the delegate for a new card to display in the container.
41+
- parameter number: number that is needed to be displayed.
42+
- parameter reusedView: the component may provide you with an unused view.
43+
- returns: correctly configured card view.
44+
*/
45+
func cardNumber(number:Int, reusedView:BaseCardView?) -> BaseCardView
46+
}
47+
48+
How to reuse a card view? There is an example in `ComponentExampleViewController.swift`:
49+
50+
func cardNumber(number: Int, reusedView: BaseCardView?) -> BaseCardView {
51+
var retView : ImageCardView? = reusedView as? ImageCardView
52+
print(" 🃏 Requested card number \(number)")
53+
if retView == nil {
54+
retView = ImageCardView(frame: CGRect(x: 0, y: 0, width: 10, height: 10))
55+
} else {
56+
print(" ✌️ View Cached ✌️ ")
57+
}
58+
retView!.imageView.image = UIImage.init(named: JusticeLeagueLogos.logoArray[number].rawValue)
59+
return retView!
60+
}
61+
62+
**Techniques in the animation:**
563

664
**Change Anchor Point of CALayer**
765

@@ -51,7 +109,7 @@ You could use 'CGFloat(-M_PI) * 0.99' to fix this.
51109

52110
**To-Do List**
53111

54-
1. reuse card view
112+
~~1. reuse card view~~
55113

56114
2. reorder card view
57115

0 commit comments

Comments
 (0)