Skip to content

Commit d8c0dcf

Browse files
Last update
1 parent 926a113 commit d8c0dcf

52 files changed

Lines changed: 1695 additions & 586 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ButtonClickStyle.xcodeproj/project.pbxproj

Lines changed: 80 additions & 22 deletions
Large diffs are not rendered by default.

ButtonClickStyle/AppDelegate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414

1515
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1616
// Override point for customization after application launch.
17-
setupWindowIfNeeded()
17+
// setupWindowIfNeeded()
1818

1919
return true
2020
}
@@ -23,7 +23,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2323
let window = UIWindow(frame: UIScreen.main.bounds)
2424

2525
// let vc = TestViewController.instantiate()
26-
let vc = ButtonListViewController.instantiate()
26+
let vc = ExampleAnimationsViewController.instantiate()
2727
let nav = UINavigationController(rootViewController: vc)
2828
nav.setNavigationBarHidden(false, animated: false)
2929
window.rootViewController = nav
Lines changed: 81 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,100 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="2mC-8m-A43">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
34
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
57
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
69
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
710
</dependencies>
811
<scenes>
12+
<!--Navigation Controller-->
13+
<scene sceneID="e1c-Qd-Qjs">
14+
<objects>
15+
<navigationController id="2mC-8m-A43" sceneMemberID="viewController">
16+
<navigationBar key="navigationBar" contentMode="scaleToFill" id="gBt-LV-vze">
17+
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
18+
<autoresizingMask key="autoresizingMask"/>
19+
</navigationBar>
20+
<connections>
21+
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="3P7-MP-HhB"/>
22+
</connections>
23+
</navigationController>
24+
<placeholder placeholderIdentifier="IBFirstResponder" id="IIA-ws-Ef4" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
25+
</objects>
26+
<point key="canvasLocation" x="-268" y="-115"/>
27+
</scene>
928
<!--View Controller-->
1029
<scene sceneID="tne-QT-ifu">
1130
<objects>
12-
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
31+
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="ButtonClickStyle" customModuleProvider="target" sceneMemberID="viewController">
1332
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
14-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
33+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
1534
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16-
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
35+
<subviews>
36+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qXM-rs-wzT">
37+
<rect key="frame" x="146" y="144" width="122" height="30"/>
38+
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
39+
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
40+
<state key="normal" title="Test Screen"/>
41+
<connections>
42+
<action selector="testScreenButtonAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="uVi-i8-Lfc"/>
43+
</connections>
44+
</button>
45+
<button opaque="NO" contentMode="scaleToFill" verticalCompressionResistancePriority="752" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="U4i-jN-1m6">
46+
<rect key="frame" x="142.5" y="184" width="129" height="30"/>
47+
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
48+
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
49+
<state key="normal" title="TestDemo Screen"/>
50+
<connections>
51+
<action selector="testDemoScreenButtonAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="LPc-xK-hkU"/>
52+
</connections>
53+
</button>
54+
<button opaque="NO" contentMode="scaleToFill" verticalCompressionResistancePriority="751" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Bw3-He-sJB">
55+
<rect key="frame" x="105" y="224" width="204" height="30"/>
56+
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
57+
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
58+
<state key="normal" title="ExampleAnimations Screen "/>
59+
<connections>
60+
<action selector="exampleAnimationsScreenButtonAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="XTw-b2-Irj"/>
61+
</connections>
62+
</button>
63+
<button opaque="NO" contentMode="scaleToFill" verticalCompressionResistancePriority="753" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mXW-y9-Vhi">
64+
<rect key="frame" x="141" y="262" width="132" height="30"/>
65+
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
66+
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
67+
<state key="normal" title="ButtonList Screen"/>
68+
<connections>
69+
<action selector="buttonListScreenButtonAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="i30-fC-Jkb"/>
70+
</connections>
71+
</button>
72+
</subviews>
1773
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
74+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
75+
<constraints>
76+
<constraint firstItem="U4i-jN-1m6" firstAttribute="top" secondItem="qXM-rs-wzT" secondAttribute="bottom" constant="10" id="5AC-Zi-Xmv"/>
77+
<constraint firstItem="mXW-y9-Vhi" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="6gz-Es-SwW"/>
78+
<constraint firstItem="qXM-rs-wzT" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="146" id="EwE-0I-jHL"/>
79+
<constraint firstItem="Bw3-He-sJB" firstAttribute="top" secondItem="U4i-jN-1m6" secondAttribute="bottom" constant="10" id="J5M-I6-KR6"/>
80+
<constraint firstItem="mXW-y9-Vhi" firstAttribute="top" secondItem="Bw3-He-sJB" secondAttribute="bottom" constant="8" symbolic="YES" id="NHz-z8-mid"/>
81+
<constraint firstItem="Bw3-He-sJB" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="NQG-Ih-XNE"/>
82+
<constraint firstItem="qXM-rs-wzT" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" constant="56" id="OBx-lA-c9u"/>
83+
<constraint firstItem="qXM-rs-wzT" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="moj-pA-DX3"/>
84+
<constraint firstItem="Bw3-He-sJB" firstAttribute="top" secondItem="U4i-jN-1m6" secondAttribute="bottom" constant="10" id="yo9-iw-cSf"/>
85+
<constraint firstItem="qXM-rs-wzT" firstAttribute="centerX" secondItem="U4i-jN-1m6" secondAttribute="centerX" id="zg8-Lb-G5U"/>
86+
</constraints>
1887
</view>
88+
<navigationItem key="navigationItem" id="U4X-kX-AuW"/>
1989
</viewController>
2090
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
2191
</objects>
92+
<point key="canvasLocation" x="468" y="-115"/>
2293
</scene>
2394
</scenes>
95+
<resources>
96+
<systemColor name="systemBackgroundColor">
97+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
98+
</systemColor>
99+
</resources>
24100
</document>

ButtonClickStyle/ButtonClickStyle/Animations/UIView+AnimationAlpha.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extension UIView {
66

77
// MARK: - Alpha
88

9-
func updateChangeAlpha(with views: [UIView], visible: Bool, value: CGFloat, duration: CGFloat?) {
9+
func buttonClickStyleAlpha(with views: [UIView], visible: Bool, value: CGFloat, duration: CGFloat?) {
1010

1111
var alpha: CGFloat = 1.0
1212
if visible != true {

ButtonClickStyle/ButtonClickStyle/Animations/UIView+AnimationAndroidPulse.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,28 @@
77

88
import UIKit
99

10-
11-
12-
1310
extension UIView {
1411

1512
// MARK: - Android Pulse
1613

17-
func androidPulseAnimation(radius: CGFloat, duration: CGFloat, dark: Bool, value: CGFloat? = nil, position: CGPoint) {
14+
func buttonClickStyleAndroidPulse(radius: CGFloat, duration: CGFloat, color: UIColor? = nil, value: CGFloat? = nil, position: CGPoint) {
15+
16+
var rcolor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 0.2786076018)
17+
18+
if let color = color {
19+
rcolor = color .withAlphaComponent(0.75)
20+
}
1821

19-
var color = dark ? #colorLiteral(red: 0, green: 0, blue: 0, alpha: 0.2786076018) : #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
2022
if let alpha = value {
21-
color = color.withAlphaComponent(alpha)
23+
rcolor = rcolor.withAlphaComponent(alpha)
2224
}
2325

2426
let to = 0 + (radius * 400) // 200
2527
// print(" 💙💜 androidPulse \(to) ")
2628

27-
let pulse = PulseAnimation(numberOfPulse: 1, radius: to, postion: position)
29+
let pulse = ButtonClickStylePulseAnimation(numberOfPulse: 1, radius: to, postion: position)
2830
pulse.animationDuration = duration
29-
pulse.backgroundColor = color.cgColor// #colorLiteral(red: 0.05282949957, green: 0.5737867104, blue: 1, alpha: 1)
31+
pulse.backgroundColor = rcolor.cgColor// #colorLiteral(red: 0.05282949957, green: 0.5737867104, blue: 1, alpha: 1)
3032
layer.insertSublayer(pulse, below: layer)
3133
}
3234

ButtonClickStyle/ButtonClickStyle/Animations/UIView+AnimationColor.swift

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extension UIView {
1616

1717
// MARK: - Change Color
1818

19-
func DesignableViewBorderUpdate() {
19+
private func buttonClickStyleDesignableBorderUpdate() {
2020
if let desFig = self as? DesignableView, desFig.brWidth != 0 {
2121

2222
if desFig.brWidth != 0 {
@@ -32,24 +32,23 @@ extension UIView {
3232
}
3333
}
3434

35-
func animationColorTouchDown(cornRadius: CGFloat? = nil, color: UIColor, alpha: CGFloat) { // .s1
36-
35+
func buttonClickStyleColorTouchDown(cornRadius: CGFloat? = nil, color: UIColor, alpha: CGFloat) { // .s1
3736

3837
let from = color.withAlphaComponent(alpha)
3938

4039
if let label = self as? UILabel {
4140
label.textColor = from
4241
}
4342
else if let desFig = self as? DesignableView, desFig.brColor != .clear {
44-
DesignableViewBorderUpdate()
43+
buttonClickStyleDesignableBorderUpdate()
4544

4645
layer.borderColor = from.cgColor
4746
} else {
4847
backgroundColor = from
4948
}
5049
}
5150

52-
func animationColor(duration: CGFloat, cornRadius: CGFloat? = nil, color: UIColor, alpha: CGFloat) { // .s1
51+
func buttonClickStyleColor(duration: CGFloat, cornRadius: CGFloat? = nil, color: UIColor, alpha: CGFloat) { // .s1
5352

5453
// return;
5554

@@ -68,10 +67,6 @@ extension UIView {
6867
to = grColor
6968
}
7069

71-
// label.textColor = from
72-
73-
// main(delay: 0.1) {
74-
7570
UIView.transition(
7671
with: label,
7772
duration: 0.01,
@@ -91,13 +86,10 @@ extension UIView {
9186
)
9287

9388
})
94-
// }
95-
96-
9789
}
9890

9991
else if let desFig = self as? DesignableView, desFig.brColor != .clear {
100-
DesignableViewBorderUpdate()
92+
buttonClickStyleDesignableBorderUpdate()
10193

10294
let to = desFig.brColor
10395
layer.borderColor = to.cgColor
@@ -107,30 +99,18 @@ extension UIView {
10799
animation2.fromValue = from.cgColor
108100
animation2.toValue = to.cgColor
109101
animation2.duration = duration
110-
// animation2.beginTime = CACurrentMediaTime() + 0.1
111-
// animation2.autoreverses = false
112102
layer.add(animation2, forKey: "animationColor")
113103
layer.borderColor = to.cgColor
114104

115105
} else {
116106

117107

118-
// let fills = layer.sublayers?.filter {
119-
// $0.name == "fill"
120-
// }
121-
// fills?.forEach {
122-
// $0.removeFromSuperlayer()
123-
// }
124-
125108
let toColor = UIColor.clear.cgColor
126109

127110
let animation = CABasicAnimation(keyPath: "backgroundColor")
128-
animation.fromValue = fromColor //UIColor.white.cgColor
111+
animation.fromValue = fromColor
129112
animation.toValue = toColor
130113
animation.duration = duration
131-
// animation.beginTime = CACurrentMediaTime() + 0.1
132-
// animation.autoreverses = false
133-
134114
layer.cornerRadius = radiusSearch(cornRadius)
135115
layer.add(animation, forKey: "animationColor")
136116
backgroundColor = .clear
@@ -164,6 +144,6 @@ extension UIColor {
164144
var inverted: UIColor {
165145
var r: CGFloat = 0.0, g: CGFloat = 0.0, b: CGFloat = 0.0, a: CGFloat = 0.0
166146
self.getRed(&r, green: &g, blue: &b, alpha: &a)
167-
return UIColor(red: (1 - r), green: (1 - g), blue: (1 - b), alpha: a) // Assuming you want the same alpha value.
147+
return UIColor(red: (1 - r), green: (1 - g), blue: (1 - b), alpha: a)
168148
}
169149
}

ButtonClickStyle/ButtonClickStyle/Animations/UIView+AnimationColorFlat.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extension UIView {
99

1010
// MARK: - Add Animation Color Flat
1111

12-
func animationColorFlat(duration: CGFloat, cornRadius: CGFloat? = nil, visible: Bool, value: CGFloat, color: UIColor? = nil) {
12+
func buttonClickStyleColorFlat(duration: CGFloat, cornRadius: CGFloat? = nil, visible: Bool, value: CGFloat, color: UIColor? = nil) {
1313

1414
guard let superview = self.superview else { return }
1515

ButtonClickStyle/ButtonClickStyle/Animations/UIView+AnimationFlash.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extension UIView {
1111

1212
// MARK: - Flash
1313

14-
func flash(value: CGFloat, duration: CGFloat) {
14+
func buttonClickStyleFlash(value: CGFloat, duration: CGFloat) {
1515

1616
let flash = CABasicAnimation(keyPath: "opacity")
1717
flash.duration = duration

ButtonClickStyle/ButtonClickStyle/Animations/UIView+AnimationPress.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ extension UIView {
55

66
// MARK: - Press
77

8-
func press(duration: CGFloat, cornRadius: CGFloat? = nil, value: CGFloat, shadow: Bool, visible: Bool) {
8+
func buttonClickStylePress(duration: CGFloat, cornRadius: CGFloat? = nil, value: CGFloat, shadow: Bool, visible: Bool) {
99
if visible {
1010
animate(duration: duration, view: self, transform: .identity)
1111
if shadow {
12-
updateLayerGray(with: [self], superView: false, cornRadius: cornRadius, visible: true, value: value, duration: duration)
12+
buttonClickStyleShadow(with: [self], superView: false, cornRadius: cornRadius, visible: true, value: value, duration: duration)
1313
}
1414
} else {
1515

1616
if shadow {
1717
let to = 1.0 - (value * 0.05)
1818
animate(duration: duration, view: self, transform: .identity.scaledBy(x: to, y: to))
19-
updateLayerGray(with: [self], superView: false, cornRadius: cornRadius, visible: false, value: value / 3 , duration: duration / 3)
19+
buttonClickStyleShadow(with: [self], superView: false, cornRadius: cornRadius, visible: false, value: value / 3 , duration: duration / 3)
2020
} else {
2121
let to = 0.45 + ((value) * 5.0)
2222
animate(duration: duration, view: self, transform: .identity.translatedBy(x: 0, y: to))

ButtonClickStyle/ButtonClickStyle/Animations/UIView+AnimationPulsate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extension UIView {
1313

1414
// MARK: - Pulsate
1515

16-
func pulsate(value: CGFloat, duration: CGFloat) {
16+
func buttonClickStylePulsate(value: CGFloat, duration: CGFloat) {
1717

1818
let pulse = CASpringAnimation(keyPath: "transform.scale")
1919
pulse.duration = duration
@@ -30,7 +30,7 @@ extension UIView {
3030

3131
// MARK: - Pulsate 2
3232

33-
func pulsateNew(duration: CGFloat, value: CGFloat, visible: Bool) {
33+
func buttonClickStylePulsateNew(duration: CGFloat, value: CGFloat, visible: Bool) {
3434
if visible {
3535
animate(duration: duration, view: self, transform: .identity)
3636
} else {

0 commit comments

Comments
 (0)