Fix toasts not adjusting font for Dynamic Type

This commit is contained in:
Shadowfacts 2022-11-20 14:15:21 -05:00
parent fb2c9b341c
commit 11e81acbc1
3 changed files with 7 additions and 3 deletions

View File

@ -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)

View File

@ -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?

View File

@ -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)
}