Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Commit 50a185f

Browse files
committed
Merge branch 'master' of github.com:amirdew/CollectionViewPagingLayout
2 parents ef46c75 + 20608bf commit 50a185f

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,27 +97,22 @@ File > Swift Packages > Add Package Dependency
9797
Just add all the files under `Lib` directory to your project
9898

9999
## How to use
100-
- make sure you imported the library
100+
- Make sure you imported the library
101101
```swift
102102
import CollectionViewPagingLayout
103103
```
104+
- Set up your `UICollectionView` as you always do (you need to use a custom class for cells)
104105
- Set the layout for your collection view:
105-
(in most cases you want a paging effect so make sure you enable it)
106+
(in most cases you want a paging effect so enable that too)
106107
```swift
107108
let layout = CollectionViewPagingLayout()
108109
collectionView.collectionViewLayout = layout
109110
collectionView.isPagingEnabled = true // enabling paging effect
110111
```
111112

112-
- Then you can set `numberOfVisibleItems`, by default it's null and that means it will load all of the cells at a time
113-
```swift
114-
layout.numberOfVisibleItems = ...
115-
```
116-
- Now you just need to conform your `UICollectionViewCell` class to `TransformableView` and start implementing your custom transforms
117-
> `progress` is a float value that represents the current position of your cell in the collection view.
118-
> When it's `0` that means the current position of the cell is exactly in the center of your collection view.
119-
> the value could be negative or positive and that represents the distance to the center of your collection view.
120-
> for instance `1` means the distance between the center of the cell and the center of your collection view is equal to your collection view width.
113+
- Now you just need to conform your `UICollectionViewCell` class to `TransformableView` and start implementing your custom transforms.
114+
115+
*Note:* you can use [Prepared Transformable Protocols](#prepared-transformable-protocols) instead of `TransformableView` if you don't want a custom effect!
121116

122117
```swift
123118
extension MyCollectionViewCell: TransformableView {
@@ -126,6 +121,11 @@ extension MyCollectionViewCell: TransformableView {
126121
}
127122
}
128123
```
124+
> `progress` is a float value that represents the current position of your cell in the collection view.
125+
> When it's `0` that means the current position of the cell is exactly in the center of your collection view.
126+
> the value could be negative or positive and that represents the distance to the center of your collection view.
127+
> for instance `1` means the distance between the center of the cell and the center of your collection view is equal to your collection view width.
128+
129129

130130
you can start with a simple transform like this:
131131
```swift
@@ -140,6 +140,11 @@ extension MyCollectionViewCell: TransformableView {
140140
}
141141
```
142142

143+
- Don't forget to set `numberOfVisibleItems`, by default it's null and that means it will load all of the cells at a time
144+
```swift
145+
layout.numberOfVisibleItems = ...
146+
```
147+
143148
## Prepared Transformable Protocols
144149

145150
There are prepared transformables to make it easier to use this library,

0 commit comments

Comments
 (0)