Skip to content

Commit fef0d62

Browse files
committed
Update
1 parent 2714f8c commit fef0d62

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

StackScrollView/Classes/StackScrollView.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ public class StackScrollView: UIScrollView {
4040

4141
public func setup() {
4242

43+
contentView.backgroundColor = UIColor.clearColor()
4344
addSubview(contentView)
4445

46+
alwaysBounceVertical = true
47+
delaysContentTouches = false
48+
keyboardDismissMode = .OnDrag
49+
4550
contentView <- [
4651
Edges(),
4752
Width().like(self, .Width),
@@ -101,6 +106,12 @@ public class StackScrollView: UIScrollView {
101106
}
102107
}
103108

109+
public func scroll(to view: UIView, animated: Bool) {
110+
111+
let targetRect = view.convertRect(view.bounds, toView: self)
112+
scrollRectToVisible(targetRect, animated: true)
113+
}
114+
104115
private func updateVerticalLayout(animated animated: Bool) {
105116

106117
func perform() {
@@ -181,11 +192,7 @@ public class StackScrollView: UIScrollView {
181192
]
182193
}
183194
}
184-
185-
views.forEach {
186-
$0.frame.size.width = contentView.bounds.width
187-
}
188-
195+
189196
if animated {
190197

191198
UIView.animateWithDuration(0.3, delay: 0, options: [.BeginFromCurrentState], animations: {

StackScrollView/Classes/StackScrollViewCellType.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@ extension StackScrollViewCellType where Self: UIView {
3838

3939
stackScrollView.setHidden(hidden, view: self, animated: animated)
4040
}
41+
42+
public func scrollToSelf(animated animated: Bool) {
43+
44+
stackScrollView.scroll(to: self, animated: animated)
45+
}
4146
}

0 commit comments

Comments
 (0)