Last active
November 30, 2016 03:54
-
-
Save GE-N/03a7fa5ad1737a7843a0fc850d85a940 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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