Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
=============================================================

Expand Down
17 changes: 13 additions & 4 deletions TORoundedButton/TORoundedButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
}

Expand All @@ -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];
}

Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down
4 changes: 0 additions & 4 deletions TORoundedButtonExample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3Rx-9D-Udo" userLabel="RoundedButton" customClass="TORoundedButton">
<rect key="frame" x="67" y="343" width="280" height="50"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" systemColor="systemBlueColor"/>
<constraints>
<constraint firstAttribute="width" constant="280" id="OXU-dJ-PiL"/>
<constraint firstAttribute="height" constant="50" id="s1F-Eq-SaU"/>
Expand Down Expand Up @@ -61,8 +60,5 @@
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemBlueColor">
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>