You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -82,14 +82,16 @@ private class UICardView: UIView {
82
82
}
83
83
84
84
85
-
classUICardContainerView:UIView{
85
+
publicclassUICardContainerView:UIView{
86
86
87
87
//MARK: Property to Configure
88
88
//All properties must be configured before 'dataSource' is asigned, and don't change after asigned.
89
89
varneedsCardCenterVertically:Bool=true //The property decide card is center vertically in container, or distance of bottom between card and contaienr is the height of card.
90
90
varenableBrightnessControl:Bool=true
91
91
varmaxVisibleCardCount:Int=10
92
92
vardefaultCardSize=CGSize(width:400, height:300)
93
+
varneedsBorder:Bool=true
94
+
varheadCardBorderWidth:CGFloat=5
93
95
94
96
vardataSource:CardContainerDataSource?{
95
97
didSet{
@@ -102,14 +104,16 @@ class UICardContainerView: UIView {
//There is a bug when you want to rotate 180, if you use UIView blcok animation, it doesn't work as expected: 1.no animation, just jump to final value; 2.rotate wrong direction.
83
-
//You could use a closed value or animate it in UIView key frame animation.
//And in key frame animtion, we can fix another bug: a view is transparent in transform rotate.
92
-
//I put the view which show the content in a container view, when the container view is vertical to screen, hide the nested content view, then we can see only the content of background color, just like the back of a card.
Copy file name to clipboardexpand all lines: README.md
+56-36
Original file line number
Diff line number
Diff line change
@@ -2,16 +2,45 @@
2
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.
3
3

4
4
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
-
Drag class files in the "Classes" folder into your project, includes CardAnimationView.swift and ImageCardView.swift.
5
+
## API
6
+
7
+
I rewrite it. Support reuse card view and pan gesture. You just need to provide number of cards and relative image.
8
+
9
+
protocol CardContainerDataSource {
10
+
func numberOfCardsForCardContainerView(cardContainerView: UICardContainerView) -> Int
[@luxorules](https://github.com/luxorules/CardAnimation/tree/Component) packaged there code before, support pan gesture, card size and custom card view, not only image view. So there are two solutions for choice now. @luxorules's solution:
15
44
16
45
Classes:
17
46
@@ -21,18 +50,15 @@ Classes:
21
50
22
51
You can custom animation behavior by set the below properties.
23
52
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)`
53
+
//Animation time for a single card animation.
54
+
public var animationsSpeed = 0.2
55
+
//Defines the card size that will be used. (width, height)
56
+
public var cardSize : (width:CGFloat, height:CGFloat)
31
57
32
58
CardAnimationView needs a data source delegate to display the content, like UICollectionView.
33
59
34
-
`public weak var dataSourceDelegate : CardAnimationViewDataSource?`
35
-
60
+
public weak var dataSourceDelegate : CardAnimationViewDataSource?
61
+
36
62
protocol CardAnimationViewDataSource : class {
37
63
func numberOfVisibleCards() -> Int
38
64
func numberOfCards() -> Int
@@ -58,10 +84,15 @@ How to reuse a card view? There is an example in `ComponentExampleViewController
From iOS8, transform and autolayout play nice. There is a blog for this: [Constraints & Transformations](http://revealapp.com/blog/constraints-and-transforms.html)
89
120
90
121
Transform doesn't affect autolayout, only constraints can affect autolayout.
91
122
92
123
Transform affects view's frame, but do nothing to view's center and bounds.
93
124
94
-
**Make flip animation background not transparent**
125
+
#### Flip animation with non-transparent background
95
126
96
127
Use a subview, and change the container view's background color to what color you want.
97
128
98
129
When the container view is vertical to screen, make the subview hidden, and after the container view back, make subview visible.
99
130
100
-
**Rotation Animation Bug in action method**
131
+
#### Rotation Animation Bug in action method
101
132
102
133
let flipTransform = CATransform3DRotate(CATransform3DIdentity, CGFloat(-M_PI), 1, 0, 0)
103
134
UIView.animateWithDuration(0.3, {
104
135
view.layer.transform = flipTransform
105
136
})
106
137
107
-
The animation will not execute and the view just change if you execute above code in an action method, like clip a button.
108
-
You could use 'CGFloat(-M_PI) * 0.99' to fix this.
109
-
110
-
Or, use UIView key frame animation, this transform works fine in key frame animation.
111
-
112
-
**To-Do List**
113
-
114
-
~~1.reuse card view~~
115
-
116
-
2.reorder card view
117
-
118
-
3.delete and add card view with pan gesture
138
+
The animation will not execute and the view just change if you execute above code in an action method, like clip a button. UIView keyFrame animation works fine.
0 commit comments