From 11e81acbc1c482a789d5310e62987e5880e4a968 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 20 Nov 2022 14:15:21 -0500 Subject: [PATCH] Fix toasts not adjusting font for Dynamic Type --- .../Screens/Timeline/TimelineGapCollectionViewCell.swift | 1 + Tusker/Views/Toast/ToastConfiguration.swift | 2 +- Tusker/Views/Toast/ToastView.swift | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Tusker/Screens/Timeline/TimelineGapCollectionViewCell.swift b/Tusker/Screens/Timeline/TimelineGapCollectionViewCell.swift index b2b39fed8e..4911384337 100644 --- a/Tusker/Screens/Timeline/TimelineGapCollectionViewCell.swift +++ b/Tusker/Screens/Timeline/TimelineGapCollectionViewCell.swift @@ -44,6 +44,7 @@ class TimelineGapCollectionViewCell: UICollectionViewCell { let label = UILabel() label.text = "Load more" label.font = .preferredFont(forTextStyle: .headline) + label.adjustsFontForContentSizeCategory = true label.textColor = .tintColor chevronView.update(direction: .above) diff --git a/Tusker/Views/Toast/ToastConfiguration.swift b/Tusker/Views/Toast/ToastConfiguration.swift index cf113e3266..024bf35b9b 100644 --- a/Tusker/Views/Toast/ToastConfiguration.swift +++ b/Tusker/Views/Toast/ToastConfiguration.swift @@ -11,7 +11,7 @@ import Pachyderm struct ToastConfiguration { var systemImageName: String? - var titleFont: UIFont = .boldSystemFont(ofSize: 14) + var titleFont: UIFont = UIFontMetrics(forTextStyle: .body).scaledFont(for: .boldSystemFont(ofSize: 14)) var title: String var subtitle: String? var actionTitle: String? diff --git a/Tusker/Views/Toast/ToastView.swift b/Tusker/Views/Toast/ToastView.swift index 86834be4c8..3ad95b8577 100644 --- a/Tusker/Views/Toast/ToastView.swift +++ b/Tusker/Views/Toast/ToastView.swift @@ -68,13 +68,15 @@ class ToastView: UIView { titleLabel.textColor = .white titleLabel.font = configuration.titleFont titleLabel.adjustsFontSizeToFitWidth = true + titleLabel.adjustsFontForContentSizeCategory = true if let subtitle = configuration.subtitle { let subtitleLabel = UILabel() subtitleLabel.text = subtitle subtitleLabel.textColor = .white subtitleLabel.numberOfLines = 0 - subtitleLabel.font = .systemFont(ofSize: 14) + subtitleLabel.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 14)) + subtitleLabel.adjustsFontForContentSizeCategory = true let vStack = UIStackView(arrangedSubviews: [ titleLabel, subtitleLabel @@ -89,7 +91,8 @@ class ToastView: UIView { if let actionTitle = configuration.actionTitle { let actionLabel = UILabel() actionLabel.text = actionTitle - actionLabel.font = .boldSystemFont(ofSize: 16) + actionLabel.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .boldSystemFont(ofSize: 16)) + actionLabel.adjustsFontForContentSizeCategory = true actionLabel.textColor = .white stack.addArrangedSubview(actionLabel) }