Skip to content

Commit 287affe

Browse files
author
Gürhan Yerlikaya
committed
added IBDesignable & IBInspectable for storyboard
1 parent 2b65eb8 commit 287affe

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

Example/ScrollableStackView/Base.lproj/Main.storyboard

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
2020
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
2121
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
22+
<subviews>
23+
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6Ei-Z0-TR9" customClass="ScrollableStackView" customModule="ScrollableStackView">
24+
<rect key="frame" x="129" y="66" width="240" height="128"/>
25+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
26+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
27+
</view>
28+
</subviews>
2229
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2330
</view>
2431
</viewController>

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ScrollableStackView
22

3-
Scroll your stack view with a smile up on your face. Written in Swift 3. Used Apple's pure auto layout.
3+
Scrollable UIStackView. Scroll your stack view with a smile up on your face. Written in Swift 3. Used Apple's pure auto layout
44

55
<!---->
66
<!--[![CI Status](http://img.shields.io/travis/Gürhan Yerlikaya/ScrollableStackView.svg?style=flat)](https://travis-ci.org/Gürhan Yerlikaya/ScrollableStackView)-->
@@ -11,10 +11,10 @@ Scroll your stack view with a smile up on your face. Written in Swift 3. Used Ap
1111

1212
### TODO
1313

14-
- [ ] add Storyboard in example project
15-
- [ ] try NSLayoutAnchor style (requires iOS 9 and later)
16-
- [ ] Carthage
17-
- [ ] Swift Package Manager
14+
- [ ] Add Storyboard in example project
15+
- [ ] Try NSLayoutAnchor style (requires iOS 9 and later)
16+
- [ ] Add Carthage support
17+
- [ ] Add Swift Package Manager support
1818

1919
## Example
2020

@@ -32,7 +32,6 @@ view.addSubview(scrollable)
3232
let rectangle = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 55))
3333
rectangle.backgroundColor = UIColor.red
3434
scrollable.stackView.addArrangedSubview(rectangle)
35-
}
3635
```
3736

3837
### Sample Code (Objective-C)

ScrollableStackView/Classes/ScrollableStackView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88

99
import UIKit
1010

11+
@IBDesignable
1112
@objc public class ScrollableStackView: UIView {
1213

1314
fileprivate var didSetupConstraints = false
1415
fileprivate var scrollView: UIScrollView!
1516
@objc open var stackView: UIStackView!
17+
@objc @IBInspectable open var spacing: CGFloat = 8
1618

1719
override public func didMoveToSuperview() {
1820
super.didMoveToSuperview()
@@ -33,7 +35,7 @@ import UIKit
3335
stackView = UIStackView(frame: scrollView.frame)
3436
stackView.translatesAutoresizingMaskIntoConstraints = false
3537
stackView.axis = .vertical
36-
stackView.spacing = 8
38+
stackView.spacing = spacing
3739
stackView.distribution = .equalSpacing
3840
scrollView.addSubview(stackView)
3941

0 commit comments

Comments
 (0)