Skip to content

Commit 53e9058

Browse files
committed
Explicitly set bar button item attributes for all states
This fixes two issues: - The bar buttons would revert to the non-custom font when disabled and pressed . - The faded color for disabled buttons was incorrectly overridden by the bar's tint color, causing disabled buttons to look enabled.
1 parent a0726c1 commit 53e9058

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Authenticator/Source/OTPAppDelegate.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,17 @@ class OTPAppDelegate: UIResponder, UIApplicationDelegate {
3434
let app = AppController()
3535

3636
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
37-
let barButtonAttributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 17, weight: UIFontWeightLight)]
38-
UIBarButtonItem.appearance().setTitleTextAttributes(barButtonAttributes, for: .normal)
37+
let barButtonItemFont = UIFont.systemFont(ofSize: 17, weight: UIFontWeightLight)
38+
let fontAttributes = [NSFontAttributeName: barButtonItemFont]
39+
UIBarButtonItem.appearance().setTitleTextAttributes(fontAttributes, for: .normal)
40+
UIBarButtonItem.appearance().setTitleTextAttributes(fontAttributes, for: .highlighted)
41+
UIBarButtonItem.appearance().setTitleTextAttributes(fontAttributes, for: .selected)
42+
43+
let disabledAttributes = [
44+
NSFontAttributeName: barButtonItemFont,
45+
NSForegroundColorAttributeName: UIColor.otpBarForegroundColor.withAlphaComponent(0.3),
46+
]
47+
UIBarButtonItem.appearance().setTitleTextAttributes(disabledAttributes, for: .disabled)
3948

4049
// Restore white-on-black style
4150
SVProgressHUD.setForegroundColor(.otpLightColor)

0 commit comments

Comments
 (0)