Skip to content

Commit edf7945

Browse files
committed
Disable separator
1 parent e8c6aa3 commit edf7945

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

StackScrollView-Demo/ViewController.swift

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,21 @@ class ViewController: UIViewController {
5151
}
5252
}
5353

54-
let cells = (0...50).map { i -> LabelStackViewCell in
54+
let topCells = (0...20).map { i -> LabelStackViewCell in
55+
LabelStackViewCell().then { cell in
56+
cell.backgroundColor = colorA
57+
cell.titleLabel.text = "\(i)"
58+
cell.detailLabel.text = "\(i)"
59+
}
60+
}
61+
62+
let mediumCells = [
63+
labelCell,
64+
switchCell,
65+
textFieldCell,
66+
]
67+
68+
let bottomCells = (20...40).map { i -> LabelStackViewCell in
5569
LabelStackViewCell().then { cell in
5670
cell.backgroundColor = colorA
5771
cell.titleLabel.text = "\(i)"
@@ -60,12 +74,7 @@ class ViewController: UIViewController {
6074
}
6175

6276
stackScrollView.append(
63-
views: [
64-
labelCell,
65-
switchCell,
66-
labelFromTextCell,
67-
textFieldCell,
68-
] + cells,
77+
views: [labelFromTextCell] + [topCells, mediumCells, bottomCells].flatMap { $0 },
6978
animated: false)
7079

7180
stackScrollView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

StackScrollView/BetaStackScrollView.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,21 @@ open class BetaStackScrollView: UIView, UITableViewDataSource, UITableViewDelega
3131
tableView.backgroundColor = UIColor.clear
3232
tableView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
3333
tableView.frame = bounds
34-
tableView.separatorStyle = .none
35-
tableView.separatorInset = .zero
3634

3735
addSubview(tableView)
3836
}
3937

4038
open override func didMoveToSuperview() {
4139
super.didMoveToSuperview()
4240
if superview != nil {
41+
tableView.separatorStyle = .none
42+
tableView.separatorColor = .clear
43+
tableView.separatorInset = .zero
4344
tableView.delegate = self
4445
tableView.dataSource = self
46+
} else {
47+
tableView.delegate = nil
48+
tableView.dataSource = nil
4549
}
4650
}
4751

@@ -79,6 +83,8 @@ open class BetaStackScrollView: UIView, UITableViewDataSource, UITableViewDelega
7983
private func createCell(view: UIView) -> UITableViewCell {
8084
let cell = UITableViewCell(frame: .zero)
8185
cell.separatorInset = .zero
86+
cell.selectionStyle = .none
87+
8288
let contentView = cell.contentView
8389
view.translatesAutoresizingMaskIntoConstraints = false
8490
contentView.addSubview(view)

0 commit comments

Comments
 (0)