Last active
October 24, 2017 06:06
-
-
Save overcyn/539725365f547272c87c49016799dd60 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
| import UIKit | |
| class CommentCountCell: UITableViewCell { | |
| lazy var child: UIView = { | |
| var child = UIView(frame: CGRect.zero) | |
| child.translatesAutoresizingMaskIntoConstraints = false | |
| child.backgroundColor = .red | |
| return child | |
| }() | |
| override init(style: UITableViewCellStyle, reuseIdentifier: String?) { | |
| super.init(style: style, reuseIdentifier: reuseIdentifier) | |
| contentView.addSubview(child) | |
| } | |
| required init?(coder: NSCoder) { | |
| super.init(coder: coder) | |
| } | |
| var shouldSetupConstraints = true | |
| override func updateConstraints() { | |
| if shouldSetupConstraints { | |
| child.topAnchor.constraint(equalTo: contentView.topAnchor).isActive = true | |
| child.leftAnchor.constraint(equalTo: contentView.leftAnchor).isActive = true | |
| child.rightAnchor.constraint(equalTo: contentView.rightAnchor).isActive = true | |
| child.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true | |
| child.heightAnchor.constraint(equalToConstant: 100).isActive = true | |
| shouldSetupConstraints = false | |
| } | |
| super.updateConstraints() | |
| } | |
| } | |
dmiedema
commented
Oct 24, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment