|
6 | 6 | [](http://cocoapods.org/pods/StackScrollView) |
7 | 7 | [](https://github.com/Carthage/Carthage) |
8 | 8 |
|
| 9 | +<img width=320 src="Resources/shot.png"> |
| 10 | + |
| 11 | +<img width=320 src="Resources/sample.gif"> |
| 12 | + |
9 | 13 | ## What is this? |
10 | 14 |
|
11 | 15 | StackScrollView builds form UI easily. |
12 | 16 |
|
13 | | -StackScrollView has internal UICollectionView. |
14 | | -Internal CollectionView calculates size of view by AutoLayout, then that display. |
| 17 | +StackScrollView includes UICollectionView. |
| 18 | +UICollectionView calculates size of view by AutoLayout, then that display. |
| 19 | +(Use `systemLayoutSizeFitting`) |
| 20 | + |
| 21 | +- We call `StackCell` instead of `Cell` on StackScrollView. |
| 22 | +- We no longer need to consider reusing Cells. |
| 23 | +- `StackCell` requires constraint based layout. |
| 24 | + |
| 25 | +## Usage |
| 26 | + |
| 27 | +### Basic usage |
| 28 | + |
| 29 | +```swift |
| 30 | +let stack = StackScrollView() |
| 31 | +stack.append(view: UIView()) |
| 32 | +``` |
| 33 | + |
| 34 | +### Create CustomCell from Code |
| 35 | + |
| 36 | +*We have to set constraints completely.* |
| 37 | + |
| 38 | +```swift |
| 39 | +final class LabelStackCell: UIView { |
| 40 | + |
| 41 | + private let label = UILabel() |
| 42 | + |
| 43 | + init(title: String) { |
| 44 | + super.init(frame: .zero) |
| 45 | + |
| 46 | + addSubview(label) |
| 47 | + label.translatesAutoresizingMaskIntoConstraints = false |
| 48 | + |
| 49 | + label.topAnchor.constraint(greaterThanOrEqualTo: topAnchor, constant: 8).isActive = true |
| 50 | + label.bottomAnchor.constraint(lessThanOrEqualTo: bottomAnchor, constant: 8).isActive = true |
| 51 | + label.rightAnchor.constraint(equalTo: rightAnchor, constant: 8).isActive = true |
| 52 | + label.leftAnchor.constraint(equalTo: leftAnchor, constant: 8).isActive = true |
| 53 | + label.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true |
| 54 | + heightAnchor.constraint(greaterThanOrEqualToConstant: 40).isActive = true |
| 55 | + |
| 56 | + label.font = UIFont.preferredFont(forTextStyle: .body) |
| 57 | + label.text = title |
| 58 | + } |
| 59 | +} |
| 60 | +``` |
| 61 | + |
| 62 | +```swift |
| 63 | +let stack = StackScrollView() |
| 64 | +stack.append(view: LabelStackCell(title: "Label")) |
| 65 | +``` |
| 66 | + |
| 67 | +### Create CustomCell from XIB |
| 68 | + |
| 69 | +// TODO: |
| 70 | + |
| 71 | +### Create everything |
| 72 | + |
| 73 | +You can create any Cell. |
| 74 | +Please, check `StackScrollView-Demo` |
15 | 75 |
|
16 | 76 | ## Author |
17 | 77 |
|
|
0 commit comments