Skip to content

Instantly share code, notes, and snippets.

@hlung
Last active May 7, 2019 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hlung/d95ea4d9116f3ac1a700534f21b1dd9f to your computer and use it in GitHub Desktop.
Save hlung/d95ea4d9116f3ac1a700534f21b1dd9f to your computer and use it in GitHub Desktop.
class ArticleView: UIView {
var totalCommentCount: Int = 0 {
didSet {
setNeedsLayout()
}
}
var hasComment: Bool = false {
didSet {
setNeedsLayout()
}
}
override func layoutSubviews() {
super.layoutSubviews()
reactionInfoView.commentCount = totalCommentCount
commentsTableHeaderView.isHidden = !hasComment
}
lazy var reactionInfoView: ReactionInfoView = {
let view = ReactionInfoView()
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = .white
return view
}()
lazy var commentsTableView: ContentFitTableView = {
let tableView = ContentFitTableView()
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.estimatedRowHeight = 154
tableView.rowHeight = UITableView.automaticDimension
return tableView
}()
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment