Skip to content

Commit a904795

Browse files
committed
Update Readme
1 parent 350fdaf commit a904795

File tree

8 files changed

+86
-15
lines changed

8 files changed

+86
-15
lines changed

README.md

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,72 @@
66
[![Platform](https://img.shields.io/cocoapods/p/StackScrollView.svg?style=flat)](http://cocoapods.org/pods/StackScrollView)
77
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
88

9+
<img width=320 src="Resources/shot.png">
10+
11+
<img width=320 src="Resources/sample.gif">
12+
913
## What is this?
1014

1115
StackScrollView builds form UI easily.
1216

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`
1575

1676
## Author
1777

Resources/sample.gif

1.34 MB
Loading

Resources/shot.png

73.9 KB
Loading

StackScrollView-Demo/Base.lproj/Main.storyboard

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16B2555" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="7T2-uk-2HS">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="7T2-uk-2HS">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
4-
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
7+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
68
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
79
</dependencies>
810
<scenes>
@@ -37,7 +39,8 @@
3739
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
3840
<subviews>
3941
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XRJ-Za-6jO">
40-
<state key="normal" title="Button"/>
42+
<rect key="frame" x="168.5" y="318.5" width="38" height="30"/>
43+
<state key="normal" title="Open"/>
4144
<connections>
4245
<segue destination="BYZ-38-t0r" kind="presentation" id="P88-30-pnT"/>
4346
</connections>

StackScrollView-Demo/LabelStackCell.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@ final class LabelStackCell: StackCellBase {
1616

1717
private let label = UILabel()
1818

19-
override init() {
19+
init(title: String) {
2020
super.init()
2121

2222
addSubview(label)
23-
label <- Edges(UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8))
23+
label.translatesAutoresizingMaskIntoConstraints = false
2424

25-
self <- Height(>=40)
25+
label.topAnchor.constraint(greaterThanOrEqualTo: topAnchor, constant: 8).isActive = true
26+
label.bottomAnchor.constraint(lessThanOrEqualTo: bottomAnchor, constant: 8).isActive = true
27+
label.rightAnchor.constraint(equalTo: rightAnchor, constant: 8).isActive = true
28+
label.leftAnchor.constraint(equalTo: leftAnchor, constant: 8).isActive = true
29+
label.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
30+
heightAnchor.constraint(greaterThanOrEqualToConstant: 40).isActive = true
2631

2732
label.font = UIFont.preferredFont(forTextStyle: .body)
28-
}
29-
30-
func set(value: String) {
31-
label.text = value
33+
label.text = title
3234
}
3335
}

StackScrollView-Demo/ViewController.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ class ViewController: UIViewController {
2424

2525
views.append(MarginStackCell(height: 96, backgroundColor: marginColor))
2626

27+
views.append(HeaderStackCell(title: "LabelStackCell", backgroundColor: marginColor))
28+
29+
views.append(LabelStackCell(title: "Label"))
30+
31+
views.append(MarginStackCell(height: 40, backgroundColor: marginColor))
32+
2733
views.append(HeaderStackCell(title: "TextFieldStackCell", backgroundColor: marginColor))
2834

2935
views.append(fullSeparator())

StackScrollView.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = 'StackScrollView'
3-
s.version = '0.5.0'
4-
s.summary = 'Scalable form builder with UIScrollView'
3+
s.version = '0.9.0'
4+
s.summary = 'Scalable form builder with UICollectionView'
55
s.homepage = 'https://github.com/muukii/StackScrollView'
66
s.license = { :type => 'MIT', :file => 'LICENSE' }
77
s.author = { 'muukii' => '[email protected]' }

shot.png

-52.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)