Skip to content

Commit

Permalink
Remove button font conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
lascic committed May 4, 2022
1 parent 3b96451 commit df23ac0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ final class UIOnboardingButton: UIButton {
convenience init(withConfiguration configuration: UIOnboardingButtonConfiguration) {
self.init(type: .system)
setTitle(configuration.title, for: .normal)
#if !targetEnvironment(macCatalyst)
backgroundColor = configuration.backgroundColor
#endif
configure()
}

Expand All @@ -30,19 +32,20 @@ final class UIOnboardingButton: UIButton {
layer.cornerCurve = .continuous
titleLabel?.numberOfLines = 0

#if !targetEnvironment(macCatalyst)
setTitleColor(.white, for: .normal)
#endif
accessibilityTraits = .button

titleLabel?.adjustsFontForContentSizeCategory = true
translatesAutoresizingMaskIntoConstraints = false
isAccessibilityElement = true

if #available(iOS 15.0, *) {
titleLabel?.font = UIFontMetrics.default.scaledFont(for: .systemFont(ofSize: traitCollection.horizontalSizeClass == .regular ? 19 : 17, weight: .bold))
// titleLabel?.maximumContentSizeCategory = UIScreenType.isiPhone6s || UIScreenType.isiPhoneSE ? .extraLarge : .accessibilityExtraLarge
} else {
titleLabel?.font = UIFontMetrics.default.scaledFont(for: .preferredFont(forTextStyle: .headline), maximumPointSize: 21)
if #available(iOS 13.4, *) {
isPointerInteractionEnabled = true
}

titleLabel?.font = UIFontMetrics.default.scaledFont(for: .systemFont(ofSize: traitCollection.horizontalSizeClass == .regular ? 19 : 17, weight: .bold))
addTarget(self, action: #selector(handleCallToActionButton), for: .touchUpInside)
}

Expand Down
8 changes: 1 addition & 7 deletions Sources/UIOnboarding/Views/UIOnboardingButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,7 @@ final class UIOnboardingButton: UIButton {
isPointerInteractionEnabled = true
}


if #available(iOS 15.0, *) {
titleLabel?.font = UIFontMetrics.default.scaledFont(for: .systemFont(ofSize: traitCollection.horizontalSizeClass == .regular ? 19 : 17, weight: .bold))
// titleLabel?.maximumContentSizeCategory = UIScreenType.isiPhone6s || UIScreenType.isiPhoneSE ? .extraLarge : .accessibilityExtraLarge
} else {
titleLabel?.font = UIFontMetrics.default.scaledFont(for: .preferredFont(forTextStyle: .headline), maximumPointSize: 21)
}
titleLabel?.font = UIFontMetrics.default.scaledFont(for: .systemFont(ofSize: traitCollection.horizontalSizeClass == .regular ? 19 : 17, weight: .bold))
addTarget(self, action: #selector(handleCallToActionButton), for: .touchUpInside)
}

Expand Down

0 comments on commit df23ac0

Please sign in to comment.