Skip to content

Commit 2eee558

Browse files
committed
a fully new doc and readme
1 parent f0b5172 commit 2eee558

22 files changed

Lines changed: 330 additions & 171 deletions

README.md

Lines changed: 78 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,39 +67,88 @@ Find a demo in the Examples folder.
6767

6868
## Properties
6969

70-
CollectionViewSlantedLayout contains six properties to customize the interface.
70+
- **slantingSize**:
71+
72+
```swift
73+
@IBInspectable var slantingSize: UInt
74+
```
75+
The slanting size. The default value of this property is `75`.
76+
77+
- **slantingDirection**:
78+
79+
```swift
80+
var slantingDirection: SlantingDirection
81+
```
82+
The slanting direction. The default value of this property is `upward`.
83+
84+
- **slantingAngle**:
85+
86+
```swift
87+
fileprivate(set) var slantingAngle: CGFloat
88+
```
89+
The angle, in radians, of the slanting. The value of this property could be used to apply a rotation transform on the cell's contentView in the `collectionView(_:cellForItemAt:)` method implementation.
90+
91+
```swift
92+
if let layout = collectionView.collectionViewLayout as? CollectionViewSlantedLayout {
93+
cell.contentView.transform = CGAffineTransform(rotationAngle: layout.rotationAngle)
94+
}
95+
```
96+
- **scrollDirection**:
97+
98+
```swift
99+
var scrollDirection: UICollectionViewScrollDirection
100+
```
101+
The scroll direction of the grid. The grid layout scrolls along one axis only, either horizontally or vertically. The default value of this property is `vertical`.
102+
103+
- **isFistCellExcluded**:
104+
105+
```swift
106+
@IBInspectable var isFistCellExcluded: Bool
107+
```
108+
Allows to disable the slanting for the first cell. Set it to `true` to disable the slanting for the first cell. The default value of this property is `false`.
109+
110+
- **isLastCellExcluded**:
111+
112+
```swift
113+
@IBInspectable var isLastCellExcluded: Bool
114+
```
115+
Allows to disable the slanting for the last cell. Set it to `true` to disable the slanting for the last cell. The default value of this property is `false`.
116+
117+
- **lineSpacing**:
118+
119+
```swift
120+
@IBInspectable var lineSpacing: CGFloat
121+
```
122+
The spacing to use between two items. The default value of this property is `10.0`.
123+
124+
- **itemSize**:
125+
126+
```swift
127+
@IBInspectable var itemSize: CGFloat
128+
```
129+
The default size to use for cells. If the delegate does not implement the `collectionView(_:layout:sizeForItemAt:)` method, the slanted layout uses the value in this property to set the size of each cell. This results in cells that all have the same size. The default value of this property is `225`.
130+
131+
- **zIndexOrder**:
132+
133+
```swift
134+
var zIndexOrder: ZIndexOrder
135+
```
136+
The zIndex order of the items in the layout. The default value of this property is `ascending`.
137+
138+
139+
## Protocols
140+
141+
The `CollectionViewDelegateSlantedLayout` protocol defines methods that let you coordinate with a `CollectionViewSlantedLayout` object to implement a slanted layout. The `CollectionViewDelegateSlantedLayout` protocol has the following methods:
71142

72143
```swift
73-
var slantingDelta: UInt
74-
var slantingDirection: SlantingDirection
75-
var firstCellSlantingEnabled: Bool
76-
var lastCellSlantingEnabled: Bool
77-
var lineSpacing: CGFloat
78-
var scrollDirection: UICollectionViewScrollDirection
79-
var itemSize: CGFloat
144+
optional func collectionView(_ collectionView: UICollectionView,
145+
layout collectionViewLayout: CollectionViewSlantedLayout,
146+
sizeForItemAt indexPath: IndexPath) -> CGFloat
80147
```
81148

82-
- _slantingDelta_ is the slanting delta. Defaults to `75`
83-
- _slantingDirection_ allows to set slanting direction. Defaults to `.upward`
84-
- _firstCellSlantingEnabled_ allows to enable the slanting for the first cell. By default, this property is set to `true`
85-
- _lastCellSlantingEnabled_ allows to enable the slanting for the last cell. By default, this property is set to `true`
86-
- _lineSpacing_ is the spacing to use between two items. Defaults to `10.0`
87-
- _scrollDirection_ is the scroll direction. Defaults to `.vertical`
88-
- _itemSize_ allows to set the item's defaulf width/height depending on the scroll direction if the delegate does not implement the collectionView(_:layout:sizeForItemAt:) method. Defaults to `225`
89-
90-
## Protocols
91-
92-
<details>
93-
<summary>
94-
```swift
95-
@IBInspectable open var slantingSize: UInt
96-
```
97-
</summary>
98-
<p>
99-
The slanting size. By default, this property is set to `75`.
100-
</p>
101-
</details>
102-
149+
This method asks the delegate for the size of the specified item’s cell.
150+
151+
If you do not implement this method, the slanted layout uses the values in its `itemSize` property to set the size of items instead. Your implementation of this method can return a fixed set of sizes or dynamically adjust the sizes based on the cell’s content.
103152

104153
## Author
105154

Sources/CollectionViewSlantedLayout.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import UIKit;
3636
/**
3737
The slanting size.
3838

39-
By default, this property is set to `75`.
39+
The default value of this property is `75`.
4040
*/
4141
@IBInspectable open var slantingSize: UInt = 75 {
4242
didSet {
@@ -46,7 +46,7 @@ import UIKit;
4646
}
4747

4848
/**
49-
The slanting direction direction.
49+
The slanting direction.
5050

5151
The default value of this property is `upward`.
5252
*/
@@ -75,9 +75,9 @@ import UIKit;
7575
The scroll direction of the grid.
7676

7777
The grid layout scrolls along one axis only, either horizontally or vertically.
78-
The default value of this property is `UICollectionViewScrollDirectionVertical`.
78+
The default value of this property is `vertical`.
7979
*/
80-
@objc open var scrollDirection: UICollectionViewScrollDirection = UICollectionViewScrollDirection.vertical{
80+
@objc open var scrollDirection: UICollectionViewScrollDirection = .vertical{
8181
didSet {
8282
updateRotationAngle()
8383
invalidateLayout()
@@ -87,7 +87,7 @@ import UIKit;
8787
/**
8888
Allows to disable the slanting for the first cell.
8989

90-
Set it to `true` to disable the slanting for the first cell. By default, this property is set to `false`.
90+
Set it to `true` to disable the slanting for the first cell. The default value of this property is `false`.
9191
*/
9292
@IBInspectable open var isFistCellExcluded: Bool = false {
9393
didSet {
@@ -98,7 +98,7 @@ import UIKit;
9898
/**
9999
Allows to disable the slanting for the last cell.
100100

101-
Set it to `true` to disable the slanting for the last cell. By default, this property is set to `false`.
101+
Set it to `true` to disable the slanting for the last cell. The default value of this property is `false`.
102102
*/
103103
@IBInspectable open var isLastCellExcluded: Bool = false {
104104
didSet {
@@ -109,7 +109,7 @@ import UIKit;
109109
/**
110110
The spacing to use between two items.
111111

112-
The spacing to use between two items. The default value of this property is 10.0.
112+
The default value of this property is 10.0.
113113
*/
114114
@IBInspectable open var lineSpacing: CGFloat = 10 {
115115
didSet {
@@ -123,7 +123,7 @@ import UIKit;
123123
If the delegate does not implement the `collectionView(_:layout:sizeForItemAt:)` method, the slanted layout
124124
uses the value in this property to set the size of each cell. This results in cells that all have the same size.
125125

126-
The default size value is 225.
126+
The default value of this property is 225.
127127
*/
128128
@IBInspectable open var itemSize: CGFloat = 225 {
129129
didSet {

docs/Classes.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ <h4>Declaration</h4>
138138
</section>
139139
</section>
140140
<section id="footer">
141-
<p>&copy; 2017 <a class="link" href="http://yassir.fr" target="_blank" rel="external">Yassir Barchi</a>. All rights reserved. (Last updated: 2017-12-30)</p>
141+
<p>&copy; 2017 <a class="link" href="http://yassir.fr" target="_blank" rel="external">Yassir Barchi</a>. All rights reserved. (Last updated: 2017-12-31)</p>
142142
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
143143
</section>
144144
</article>

docs/Classes/CollectionViewSlantedLayout.html

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,26 @@ <h1>CollectionViewSlantedLayout</h1>
8383
<li class="item">
8484
<div>
8585
<code>
86-
<a name="/c:@M@CollectionViewSlantedLayout@objc(cs)CollectionViewSlantedLayout(py)slantingDelta"></a>
87-
<a name="//apple_ref/swift/Property/slantingDelta" class="dashAnchor"></a>
88-
<a class="token" href="#/c:@M@CollectionViewSlantedLayout@objc(cs)CollectionViewSlantedLayout(py)slantingDelta">slantingDelta</a>
86+
<a name="/c:@M@CollectionViewSlantedLayout@objc(cs)CollectionViewSlantedLayout(py)slantingSize"></a>
87+
<a name="//apple_ref/swift/Property/slantingSize" class="dashAnchor"></a>
88+
<a class="token" href="#/c:@M@CollectionViewSlantedLayout@objc(cs)CollectionViewSlantedLayout(py)slantingSize">slantingSize</a>
8989
</code>
9090
</div>
9191
<div class="height-container">
9292
<div class="pointer-container"></div>
9393
<section class="section">
9494
<div class="pointer"></div>
9595
<div class="abstract">
96-
<p>The slanting delta.</p>
96+
<p>The slanting size.</p>
9797

98-
<p>By default, this property is set to <code>75</code>.</p>
98+
<p>The default value of this property is <code>75</code>.</p>
9999

100100
</div>
101101
<div class="declaration">
102102
<h4>Declaration</h4>
103103
<div class="language">
104104
<p class="aside-title">Swift</p>
105-
<pre class="highlight"><code><span class="kd">@IBInspectable</span> <span class="n">open</span> <span class="k">var</span> <span class="nv">slantingDelta</span><span class="p">:</span> <span class="kt">UInt</span> <span class="o">=</span> <span class="mi">75</span></code></pre>
105+
<pre class="highlight"><code><span class="kd">@IBInspectable</span> <span class="n">open</span> <span class="k">var</span> <span class="nv">slantingSize</span><span class="p">:</span> <span class="kt">UInt</span> <span class="o">=</span> <span class="mi">75</span></code></pre>
106106

107107
</div>
108108
</div>
@@ -122,7 +122,7 @@ <h4>Declaration</h4>
122122
<section class="section">
123123
<div class="pointer"></div>
124124
<div class="abstract">
125-
<p>The slanting direction direction.</p>
125+
<p>The slanting direction.</p>
126126

127127
<p>The default value of this property is <code>upward</code>.</p>
128128

@@ -188,14 +188,14 @@ <h4>Declaration</h4>
188188
<p>The scroll direction of the grid.</p>
189189

190190
<p>The grid layout scrolls along one axis only, either horizontally or vertically.
191-
The default value of this property is <code>UICollectionViewScrollDirectionVertical</code>.</p>
191+
The default value of this property is <code>vertical</code>.</p>
192192

193193
</div>
194194
<div class="declaration">
195195
<h4>Declaration</h4>
196196
<div class="language">
197197
<p class="aside-title">Swift</p>
198-
<pre class="highlight"><code><span class="kd">@objc</span> <span class="n">open</span> <span class="k">var</span> <span class="nv">scrollDirection</span><span class="p">:</span> <span class="kt">UICollectionViewScrollDirection</span> <span class="o">=</span> <span class="kt">UICollectionViewScrollDirection</span><span class="o">.</span><span class="n">vertical</span></code></pre>
198+
<pre class="highlight"><code><span class="kd">@objc</span> <span class="n">open</span> <span class="k">var</span> <span class="nv">scrollDirection</span><span class="p">:</span> <span class="kt">UICollectionViewScrollDirection</span> <span class="o">=</span> <span class="o">.</span><span class="n">vertical</span></code></pre>
199199

200200
</div>
201201
</div>
@@ -205,9 +205,9 @@ <h4>Declaration</h4>
205205
<li class="item">
206206
<div>
207207
<code>
208-
<a name="/c:@M@CollectionViewSlantedLayout@objc(cs)CollectionViewSlantedLayout(py)firstCellSlantingEnabled"></a>
209-
<a name="//apple_ref/swift/Property/firstCellSlantingEnabled" class="dashAnchor"></a>
210-
<a class="token" href="#/c:@M@CollectionViewSlantedLayout@objc(cs)CollectionViewSlantedLayout(py)firstCellSlantingEnabled">firstCellSlantingEnabled</a>
208+
<a name="/c:@M@CollectionViewSlantedLayout@objc(cs)CollectionViewSlantedLayout(py)isFistCellExcluded"></a>
209+
<a name="//apple_ref/swift/Property/isFistCellExcluded" class="dashAnchor"></a>
210+
<a class="token" href="#/c:@M@CollectionViewSlantedLayout@objc(cs)CollectionViewSlantedLayout(py)isFistCellExcluded">isFistCellExcluded</a>
211211
</code>
212212
</div>
213213
<div class="height-container">
@@ -217,14 +217,14 @@ <h4>Declaration</h4>
217217
<div class="abstract">
218218
<p>Allows to disable the slanting for the first cell.</p>
219219

220-
<p>Set it to <code>false</code> to disable the slanting for the first cell. By default, this property is set to <code>true</code>.</p>
220+
<p>Set it to <code>true</code> to disable the slanting for the first cell. The default value of this property is <code>false</code>.</p>
221221

222222
</div>
223223
<div class="declaration">
224224
<h4>Declaration</h4>
225225
<div class="language">
226226
<p class="aside-title">Swift</p>
227-
<pre class="highlight"><code><span class="kd">@IBInspectable</span> <span class="n">open</span> <span class="k">var</span> <span class="nv">firstCellSlantingEnabled</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">true</span></code></pre>
227+
<pre class="highlight"><code><span class="kd">@IBInspectable</span> <span class="n">open</span> <span class="k">var</span> <span class="nv">isFistCellExcluded</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">false</span></code></pre>
228228

229229
</div>
230230
</div>
@@ -234,9 +234,9 @@ <h4>Declaration</h4>
234234
<li class="item">
235235
<div>
236236
<code>
237-
<a name="/c:@M@CollectionViewSlantedLayout@objc(cs)CollectionViewSlantedLayout(py)lastCellSlantingEnabled"></a>
238-
<a name="//apple_ref/swift/Property/lastCellSlantingEnabled" class="dashAnchor"></a>
239-
<a class="token" href="#/c:@M@CollectionViewSlantedLayout@objc(cs)CollectionViewSlantedLayout(py)lastCellSlantingEnabled">lastCellSlantingEnabled</a>
237+
<a name="/c:@M@CollectionViewSlantedLayout@objc(cs)CollectionViewSlantedLayout(py)isLastCellExcluded"></a>
238+
<a name="//apple_ref/swift/Property/isLastCellExcluded" class="dashAnchor"></a>
239+
<a class="token" href="#/c:@M@CollectionViewSlantedLayout@objc(cs)CollectionViewSlantedLayout(py)isLastCellExcluded">isLastCellExcluded</a>
240240
</code>
241241
</div>
242242
<div class="height-container">
@@ -246,14 +246,14 @@ <h4>Declaration</h4>
246246
<div class="abstract">
247247
<p>Allows to disable the slanting for the last cell.</p>
248248

249-
<p>Set it to <code>false</code> to disable the slanting for the last cell. By default, this property is set to <code>true</code>.</p>
249+
<p>Set it to <code>true</code> to disable the slanting for the last cell. The default value of this property is <code>false</code>.</p>
250250

251251
</div>
252252
<div class="declaration">
253253
<h4>Declaration</h4>
254254
<div class="language">
255255
<p class="aside-title">Swift</p>
256-
<pre class="highlight"><code><span class="kd">@IBInspectable</span> <span class="n">open</span> <span class="k">var</span> <span class="nv">lastCellSlantingEnabled</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">true</span></code></pre>
256+
<pre class="highlight"><code><span class="kd">@IBInspectable</span> <span class="n">open</span> <span class="k">var</span> <span class="nv">isLastCellExcluded</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">false</span></code></pre>
257257

258258
</div>
259259
</div>
@@ -275,7 +275,7 @@ <h4>Declaration</h4>
275275
<div class="abstract">
276276
<p>The spacing to use between two items.</p>
277277

278-
<p>The spacing to use between two items. The default value of this property is 10.0.</p>
278+
<p>The default value of this property is 10.0.</p>
279279

280280
</div>
281281
<div class="declaration">
@@ -307,7 +307,7 @@ <h4>Declaration</h4>
307307
<p>If the delegate does not implement the <code>collectionView(_:layout:sizeForItemAt:)</code> method, the slanted layout
308308
uses the value in this property to set the size of each cell. This results in cells that all have the same size.</p>
309309

310-
<p>The default size value is 225.</p>
310+
<p>The default value of this property is 225.</p>
311311

312312
</div>
313313
<div class="declaration">
@@ -355,7 +355,7 @@ <h4>Declaration</h4>
355355
</section>
356356
</section>
357357
<section id="footer">
358-
<p>&copy; 2017 <a class="link" href="http://yassir.fr" target="_blank" rel="external">Yassir Barchi</a>. All rights reserved. (Last updated: 2017-12-30)</p>
358+
<p>&copy; 2017 <a class="link" href="http://yassir.fr" target="_blank" rel="external">Yassir Barchi</a>. All rights reserved. (Last updated: 2017-12-31)</p>
359359
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
360360
</section>
361361
</article>

docs/Enums.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ <h4>Declaration</h4>
130130
</section>
131131
</section>
132132
<section id="footer">
133-
<p>&copy; 2017 <a class="link" href="http://yassir.fr" target="_blank" rel="external">Yassir Barchi</a>. All rights reserved. (Last updated: 2017-12-30)</p>
133+
<p>&copy; 2017 <a class="link" href="http://yassir.fr" target="_blank" rel="external">Yassir Barchi</a>. All rights reserved. (Last updated: 2017-12-31)</p>
134134
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
135135
</section>
136136
</article>

docs/Enums/SlantingDirection.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ <h4>Declaration</h4>
139139
</section>
140140
</section>
141141
<section id="footer">
142-
<p>&copy; 2017 <a class="link" href="http://yassir.fr" target="_blank" rel="external">Yassir Barchi</a>. All rights reserved. (Last updated: 2017-12-30)</p>
142+
<p>&copy; 2017 <a class="link" href="http://yassir.fr" target="_blank" rel="external">Yassir Barchi</a>. All rights reserved. (Last updated: 2017-12-31)</p>
143143
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
144144
</section>
145145
</article>

0 commit comments

Comments
 (0)