diff --git a/CHANGELOG.md b/CHANGELOG.md index b074a1c..be12cd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ x.y.z Release Notes (yyyy-MM-dd) ============================================================= +### Fixed + +* Re-calculating the darker tap color when moving between light and dark mode. +* Changed the tap-down animation to always use a fluid zoom animation. + 1.1.3 Release Notes (2020-12-12) ============================================================= diff --git a/TORoundedButton/TORoundedButton.m b/TORoundedButton/TORoundedButton.m index 27937ed..96e20e8 100644 --- a/TORoundedButton/TORoundedButton.m +++ b/TORoundedButton/TORoundedButton.m @@ -90,7 +90,7 @@ - (void)roundedButtonCommonInit _tappedTextAlpha = (_tappedTextAlpha > FLT_EPSILON) ?: 1.0f; _tapAnimationDuration = (_tapAnimationDuration > FLT_EPSILON) ?: 0.4f; _tappedButtonScale = (_tappedButtonScale > FLT_EPSILON) ?: 0.97f; - _tappedTintColorBrightnessOffset = !TO_ROUNDED_BUTTON_FLOAT_IS_ZERO(_tappedTintColorBrightnessOffset) ?: -0.1f; + _tappedTintColorBrightnessOffset = !TO_ROUNDED_BUTTON_FLOAT_IS_ZERO(_tappedTintColorBrightnessOffset) ?: -0.15f; // Set the tapped tint color if we've set to dynamically calculate it [self updateTappedTintColorForTintColor]; @@ -169,8 +169,13 @@ - (void)updateTappedTintColorForTintColor if (TO_ROUNDED_BUTTON_FLOAT_IS_ZERO(_tappedTintColorBrightnessOffset)) { return; } - - _tappedTintColor = [[self class] brightnessAdjustedColorWithColor:self.tintColor + + UIColor *tintColor = self.tintColor; + if (@available(iOS 13.0, *)) { + tintColor = [tintColor resolvedColorWithTraitCollection:self.traitCollection]; + } + + _tappedTintColor = [[self class] brightnessAdjustedColorWithColor:tintColor amount:_tappedTintColorBrightnessOffset]; } @@ -182,7 +187,7 @@ - (void)didTouchDownInside // The user touched their finger down into the button bounds [self setLabelAlphaTappedAnimated:NO]; - [self setBackgroundColorTappedAnimated:NO]; + [self setBackgroundColorTappedAnimated:YES]; [self setButtonScaledTappedAnimated:YES]; } @@ -252,6 +257,8 @@ - (void)setBackgroundColorTappedAnimated:(BOOL)animated self.titleLabel.backgroundColor = [UIColor clearColor]; [UIView animateWithDuration:self.tapAnimationDuration delay:0.0f + usingSpringWithDamping:1.0f + initialSpringVelocity:0.5f options:UIViewAnimationOptionBeginFromCurrentState animations:animationBlock completion:completionBlock]; @@ -284,6 +291,8 @@ - (void)setLabelAlphaTappedAnimated:(BOOL)animated // Animate the button alpha [UIView animateWithDuration:self.tapAnimationDuration delay:0.0f + usingSpringWithDamping:1.0f + initialSpringVelocity:0.5f options:UIViewAnimationOptionBeginFromCurrentState animations:animationBlock completion:nil]; diff --git a/TORoundedButtonExample/Base.lproj/Main.storyboard b/TORoundedButtonExample/Base.lproj/Main.storyboard index 9a74d36..a763b67 100644 --- a/TORoundedButtonExample/Base.lproj/Main.storyboard +++ b/TORoundedButtonExample/Base.lproj/Main.storyboard @@ -20,7 +20,6 @@ - @@ -61,8 +60,5 @@ - - -