-
-
Save YoomamaFTW/a6e81d5232be5716362909c3588673b2 to your computer and use it in GitHub Desktop.
Problem with the label being covered up.
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 SummaryNoteTableViewCell: UITableViewCell { | |
let titleLabel = UILabel() | |
let createdLabel = UILabel() | |
let summaryLabel = UILabel() | |
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | |
super.init(style: style, reuseIdentifier: reuseIdentifier) | |
titleLabel.numberOfLines = 2 | |
titleLabel.lineBreakMode = .byWordWrapping | |
titleLabel.font = UIFont.boldSystemFont(ofSize: 23) | |
summaryLabel.numberOfLines = 4 | |
summaryLabel.lineBreakMode = .byWordWrapping | |
contentView.clipsToBounds = true | |
titleLabel.translatesAutoresizingMaskIntoConstraints = false | |
createdLabel.translatesAutoresizingMaskIntoConstraints = false | |
summaryLabel.translatesAutoresizingMaskIntoConstraints = false | |
contentView.addSubview(titleLabel) | |
contentView.addSubview(createdLabel) | |
contentView.addSubview(summaryLabel) | |
let lg = contentView.safeAreaLayoutGuide | |
NSLayoutConstraint.activate([ | |
titleLabel.topAnchor.constraint(equalTo: lg.topAnchor), | |
titleLabel.leadingAnchor.constraint(equalTo: lg.leadingAnchor), | |
titleLabel.trailingAnchor.constraint(equalTo: lg.trailingAnchor), | |
titleLabel.bottomAnchor.constraint(equalTo: createdLabel.topAnchor), | |
createdLabel.leadingAnchor.constraint(equalTo: lg.leadingAnchor), | |
createdLabel.trailingAnchor.constraint(equalTo: lg.trailingAnchor), | |
createdLabel.bottomAnchor.constraint(equalTo: summaryLabel.topAnchor, constant: -8), | |
summaryLabel.leadingAnchor.constraint(equalTo: lg.leadingAnchor), | |
summaryLabel.trailingAnchor.constraint(equalTo: lg.trailingAnchor), | |
summaryLabel.bottomAnchor.constraint(equalTo: lg.bottomAnchor) | |
]) | |
} | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
contentView.frame = contentView.frame.inset(by: UIEdgeInsets(top: 15, left: 17, bottom: 15, right: 17)) | |
} | |
required init?(coder aDecoder: NSCoder) {super.init(coder: aDecoder)} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm having trouble with this custom cell. For some reason, the bottom label is being covered up for some of the cells, especially when the summaryLabel has one line. Half the time when the summaryLabel is just one line, it's either fully shown or partially or almost fully covered up. Anyone know why that it or how to fix it?