Created
September 11, 2018 07:58
-
-
Save ShoMasegi/627a563918cce72d33d5e55f304e52a3 to your computer and use it in GitHub Desktop.
hatena_WithoutStoryboard_tableviewcell_layout
This file contains 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 EventTableViewCell: UITableViewCell, Reusable { | |
.... | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
contentView.layoutIfNeeded() | |
iconImageView.layer.cornerRadius = iconImageView.frame.height / 2 | |
} | |
private lazy var iconImageView: UIImageView = { | |
let imageView = UIImageView() | |
imageView.clipsToBounds = true | |
imageView.contentMode = .scaleAspectFill | |
imageView.backgroundColor = .lightGray | |
return imageView | |
}() | |
private lazy var eventLabel: UILabel = {...}() | |
private lazy var repoLabel: UILabel = {...}() | |
private func setupSubviews() { | |
[iconImageView, eventLabel, repoLabel].forEach(contentView.addSubview) | |
iconImageView.snp.makeConstraints { | |
$0.height.width.equalTo(40) | |
$0.top.left.equalToSuperview().inset(16) | |
} | |
eventLabel.snp.makeConstraints { | |
$0.left.equalTo(iconImageView.snp.right).offset(16) | |
$0.right.lessThanOrEqualToSuperview().offset(-24) | |
$0.top.equalTo(iconImageView).offset(2) | |
} | |
repoLabel.snp.makeConstraints { | |
$0.left.equalTo(iconImageView.snp.right).offset(16) | |
$0.right.equalToSuperview().inset(24) | |
$0.top.equalTo(eventLabel.snp.bottom).offset(2) | |
$0.bottom.equalToSuperview().inset(16) | |
} | |
} | |
.... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment