💄 Enable trunction with NSMutableParagraphStyle

This commit is contained in:
Stuart Breckenridge committed 2025-08-16 18:56:30 +08:00
1 parent 49e22cacb4
commit 4eca8f227a
2 files changed
+6 -2

No files matched your search

@@ -92,12 +92,13 @@ class MainTimelineFeedCell: UITableViewCell {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.minimumLineHeight = UIFont.preferredFont(forTextStyle: .headline).pointSize
paragraphStyle.maximumLineHeight = UIFont.preferredFont(forTextStyle: .headline).pointSize
paragraphStyle.lineBreakMode = .byTruncatingTail
let titleAttributes: [NSAttributedString.Key: Any] = [
.font: UIFont.preferredFont(forTextStyle: .headline),
.paragraphStyle: paragraphStyle,
.foregroundColor: isSelected ? UIColor.white : UIColor.label
]
let titleWithNewline = cellData.title + "\n"
let titleWithNewline = cellData.title + (cellData.summary != "" ? "\n" : "" )
let titleAttributed = NSAttributedString(string: titleWithNewline, attributes: titleAttributes)
attributedCellText.append(titleAttributed)
}
@@ -105,6 +106,7 @@ class MainTimelineFeedCell: UITableViewCell {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.minimumLineHeight = UIFont.preferredFont(forTextStyle: .body).pointSize
paragraphStyle.maximumLineHeight = UIFont.preferredFont(forTextStyle: .body).pointSize
paragraphStyle.lineBreakMode = .byTruncatingTail
let summaryAttributes: [NSAttributedString.Key: Any] = [
.font: UIFont.preferredFont(forTextStyle: .body),
.paragraphStyle: paragraphStyle,
@@ -121,12 +121,13 @@ class MainTimelineIconFeedCell: UITableViewCell {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.minimumLineHeight = UIFont.preferredFont(forTextStyle: .headline).pointSize
paragraphStyle.maximumLineHeight = UIFont.preferredFont(forTextStyle: .headline).pointSize
paragraphStyle.lineBreakMode = .byTruncatingTail
let titleAttributes: [NSAttributedString.Key: Any] = [
.font: UIFont.preferredFont(forTextStyle: .headline),
.paragraphStyle: paragraphStyle,
.foregroundColor: isSelected ? UIColor.white : UIColor.label
]
let titleWithNewline = cellData.title + "\n"
let titleWithNewline = cellData.title + (cellData.summary != "" ? "\n" : "" )
let titleAttributed = NSAttributedString(string: titleWithNewline, attributes: titleAttributes)
attributedCellText.append(titleAttributed)
}
@@ -134,6 +135,7 @@ class MainTimelineIconFeedCell: UITableViewCell {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.minimumLineHeight = UIFont.preferredFont(forTextStyle: .body).pointSize
paragraphStyle.maximumLineHeight = UIFont.preferredFont(forTextStyle: .body).pointSize
paragraphStyle.lineBreakMode = .byTruncatingTail
let summaryAttributes: [NSAttributedString.Key: Any] = [
.font: UIFont.preferredFont(forTextStyle: .body),
.paragraphStyle: paragraphStyle,