Skip to content

Commit

Permalink
Update top bar themeing in iOS 13 to fix transparent background
Browse files Browse the repository at this point in the history
  • Loading branch information
davidme-stripe committed Sep 9, 2019
1 parent afc9d67 commit 8e57545
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Stripe/UIBarButtonItem+Stripe.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ - (void)stp_setTheme:(STPTheme *)theme {
NSForegroundColorAttributeName: theme.secondaryForegroundColor,
}
forState:UIControlStateDisabled];
[self setTitleTextAttributes:@{
NSFontAttributeName: self.style == UIBarButtonItemStylePlain ? theme.font : theme.emphasisFont,
NSForegroundColorAttributeName: theme.accentColor,
}
forState:UIControlStateHighlighted];
}

@end
Expand Down
32 changes: 32 additions & 0 deletions Stripe/UINavigationBar+Stripe_Theme.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,38 @@ - (void)setStp_theme:(STPTheme *)theme {
NSFontAttributeName: theme.emphasisFont,
NSForegroundColorAttributeName: theme.primaryForegroundColor,
};

if (@available(iOS 13.0, *)) {
self.standardAppearance.backgroundColor = theme.secondaryBackgroundColor;
self.standardAppearance.titleTextAttributes = self.titleTextAttributes;
self.standardAppearance.largeTitleTextAttributes = self.largeTitleTextAttributes;
self.standardAppearance.buttonAppearance.normal.titleTextAttributes = @{
NSFontAttributeName: theme.font,
NSForegroundColorAttributeName: theme.accentColor,
};
self.standardAppearance.buttonAppearance.highlighted.titleTextAttributes = @{
NSFontAttributeName: theme.font,
NSForegroundColorAttributeName: theme.accentColor,
};
self.standardAppearance.buttonAppearance.disabled.titleTextAttributes = @{
NSFontAttributeName: theme.font,
NSForegroundColorAttributeName: theme.secondaryForegroundColor,
};
self.standardAppearance.doneButtonAppearance.normal.titleTextAttributes = @{
NSFontAttributeName: theme.emphasisFont,
NSForegroundColorAttributeName: theme.accentColor,
};
self.standardAppearance.doneButtonAppearance.highlighted.titleTextAttributes = @{
NSFontAttributeName: theme.emphasisFont,
NSForegroundColorAttributeName: theme.accentColor,
};
self.standardAppearance.doneButtonAppearance.disabled.titleTextAttributes = @{
NSFontAttributeName: theme.emphasisFont,
NSForegroundColorAttributeName: theme.secondaryForegroundColor,
};
self.scrollEdgeAppearance = self.standardAppearance;
self.compactAppearance = self.standardAppearance;
}
}


Expand Down

0 comments on commit 8e57545

Please sign in to comment.