From 4b77d74308a5964d3def7f59a0de9fb3bf019ec0 Mon Sep 17 00:00:00 2001 From: Des Marks Date: Fri, 24 Feb 2023 09:32:12 -0800 Subject: [PATCH] PillButton text should not scale with DynamicType. (#1601) Set the `shouldScale` parameter to `false`. --- ios/FluentUI/Pill Button Bar/PillButton.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ios/FluentUI/Pill Button Bar/PillButton.swift b/ios/FluentUI/Pill Button Bar/PillButton.swift index b1d009df00..69287ae74b 100644 --- a/ios/FluentUI/Pill Button Bar/PillButton.swift +++ b/ios/FluentUI/Pill Button Bar/PillButton.swift @@ -151,7 +151,7 @@ open class PillButton: UIButton, TokenizedControlInternal { } } else { setTitle(pillBarItem.title, for: .normal) - titleLabel?.font = .fluent(titleFont) + titleLabel?.font = UIFont.fluent(titleFont, shouldScale: false) contentEdgeInsets = UIEdgeInsets(top: Constants.topInset, left: Constants.horizontalInset, @@ -219,9 +219,16 @@ open class PillButton: UIButton, TokenizedControlInternal { private func updateAttributedTitle() { let itemTitle = pillBarItem.title var attributedTitle = AttributedString(itemTitle) - attributedTitle.font = .fluent(titleFont) + attributedTitle.font = UIFont.fluent(titleFont, shouldScale: false) configuration?.attributedTitle = attributedTitle + let attributedTitleTransformer = UIConfigurationTextAttributesTransformer { incoming in + var outgoing = incoming + outgoing.font = UIFont.fluent(self.titleFont, shouldScale: false) + return outgoing + } + configuration?.titleTextAttributesTransformer = attributedTitleTransformer + // Workaround for Apple bug: when UIButton.Configuration is used with UIControl's isSelected = true, accessibilityLabel doesn't get set automatically accessibilityLabel = itemTitle