Skip to content

Instantly share code, notes, and snippets.

@GE-N
Last active November 30, 2016 03:54
Show Gist options
  • Save GE-N/03a7fa5ad1737a7843a0fc850d85a940 to your computer and use it in GitHub Desktop.
Save GE-N/03a7fa5ad1737a7843a0fc850d85a940 to your computer and use it in GitHub Desktop.
class PollCell: UITableViewCell {
var header: HeaderView!
var pollContent: PollMultipleChoicesView!
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
backgroundColor = UIColor.lightGray
header = HeaderView()
contentView.addSubview(header)
header.snp.makeConstraints { (make) in
make.top.equalTo(0)
make.left.equalTo(0)
make.right.equalTo(0)
}
pollContent = PollMultipleChoicesView()
contentView.addSubview(pollContent)
pollContent.snp.makeConstraints { (make) in
make.top.equalTo(header.snp.bottom)
make.left.equalTo(0)
make.right.equalTo(0)
make.bottom.equalTo(0)
}
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class Table: UITableViewController {
override func viewDidLoad() {
tableView.estimatedRowHeight = 100
tableView.rowHeight = UITableViewAutomaticDimension
tableView.translatesAutoresizingMaskIntoConstraints = false
}
override func tableView(_ tableView: UITableView,
numberOfRowsInSection section: Int) -> Int {
return 1
}
override func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return PollCell(style: .default, reuseIdentifier: nil)
}
}
let tableVC = Table(style: .plain)
PlaygroundPage.current.liveView = tableVC.view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment