Make attributed titles work on iOS

This commit is contained in:
Nate Weaver
2020-04-15 16:34:16 -05:00
parent dc787620c5
commit 6aff83481f
4 changed files with 65 additions and 21 deletions

View File

@@ -148,7 +148,7 @@ private extension MasterTimelineTableViewCell {
func updateTitleView() {
titleView.font = MasterTimelineDefaultCellLayout.titleFont
titleView.textColor = labelColor
updateTextFieldText(titleView, cellData?.title)
updateTextFieldAttributedText(titleView, cellData?.attributedTitle)
}
func updateSummaryView() {
@@ -170,6 +170,19 @@ private extension MasterTimelineTableViewCell {
setNeedsLayout()
}
}
func updateTextFieldAttributedText(_ label: UILabel, _ text: NSAttributedString?) {
var s = text ?? NSAttributedString(string: "")
if let fieldFont = label.font, let color = label.textColor {
s = s.adding(font: fieldFont, color: color)
}
if label.attributedText != s {
label.attributedText = s
setNeedsLayout()
}
}
func updateFeedNameView() {
switch cellData.showFeedName {