Skip to content

Commit 67ebaa4

Browse files
committed
Solved conflicts
2 parents 72499cf + ed2155d commit 67ebaa4

File tree

1 file changed

+71
-3
lines changed

1 file changed

+71
-3
lines changed

README.md

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,92 @@
44
[![License](https://img.shields.io/cocoapods/l/SnappingLayout.svg?style=flat)](https://cocoapods.org/pods/SnappingLayout)
55
[![Platform](https://img.shields.io/cocoapods/p/SnappingLayout.svg?style=flat)](https://cocoapods.org/pods/SnappingLayout)
66

7-
## Example
7+
## Description
88

9-
To run the example project, clone the repo, and run `pod install` from the Example directory first.
9+
**SnappingLayout** enables a snap behaviour for `UICollectionViews`.
10+
It works with horizontal scrolling and there are 3 different types: left, center and right.
11+
You can scroll your collection view and it will automatically snap to the chosen position after decelerating.
12+
13+
The snap supports all kinds of collection view configurations: with `sectionInset`, `minimumLineSpacing`, `contentInset` and so forth.
1014

1115
## Requirements
1216

1317
iOS 9.0
18+
1419
Swift 4.2
1520

1621
## Installation
1722

18-
SnappingLayout is available through [CocoaPods](https://cocoapods.org). To install
23+
**SnappingLayout** is available through [CocoaPods](https://cocoapods.org). To install
1924
it, simply add the following line to your Podfile:
2025

2126
```ruby
2227
pod 'SnappingLayout'
2328
```
2429

30+
## Example Project
31+
32+
To run the example project, clone the repo, and run pod install from the Example directory first.
33+
Open **SnappingPresentationViewController** to see the code needed to implement the snapping.
34+
35+
## Usage
36+
37+
Just use **SnappingLayout** as a replacement for the traditional **UICollectionViewFlowLayout**.
38+
39+
It's as simple as:
40+
1. Importing it:
41+
```
42+
import SnappingLayout
43+
```
44+
2. Instantiating it:
45+
```
46+
let snappingLayout = SnappingLayout()
47+
```
48+
3. And using it:
49+
```
50+
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: snappingLayout)
51+
```
52+
4. Set the deceleration rate of the collection view to fast:
53+
```
54+
collectionView.decelerationRate = .fast
55+
```
56+
57+
There are three types of `snappingLayout`: left, center and right.
58+
59+
### Left
60+
61+
This is the **default value** when a new instance of `snappingLayout` is created and it will snap the position of the cell to the left side of the collection view.
62+
63+
```
64+
let snappingLayout = SnappingLayout()
65+
snappingLayout.snapPosition = .left
66+
```
67+
68+
![left](readmeImages/left.gif)
69+
70+
### Center
71+
72+
This will snap the position of the cell to the center of the collection view.
73+
74+
```
75+
let snappingLayout = SnappingLayout()
76+
snappingLayout.snapPosition = .center
77+
```
78+
79+
![center](readmeImages/center.gif)
80+
81+
### Right
82+
83+
This will snap the position of the cell to the right of the collection view.
84+
85+
```
86+
let snappingLayout = SnappingLayout()
87+
snappingLayout.snapPosition = .right
88+
```
89+
90+
![right](readmeImages/right.gif)
91+
92+
2593
## Author
2694

2795

0 commit comments

Comments
 (0)