Skip to content

Commit fad12b8

Browse files
author
szl
committed
Readme
1 parent bee5903 commit fad12b8

File tree

6 files changed

+39
-13
lines changed

6 files changed

+39
-13
lines changed

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Installing and Usage
2727

2828
Effect Picture
2929
====================
30-
<img src="Resources/STAlertView01.png" width="25%" height="25%"><img src="Resources/STAlertView02.png" width="25%" height="25%"><img src="Resources/STGradientButton01.png" width="25%" height="25%"><img src="Resources/STGradientView01.png" width="25%" height="25%"><img src="Resources/STHUD01.png" width="25%" height="25%"><img src="Resources/STHUD02.png" width="25%" height="25%"><img src="Resources/STMoveButton01.png" width="25%" height="25%"><img src="Resources/STPhoneTextField01.png" width="25%" height="25%"><img src="Resources/STProgressView01.png" width="25%" height="25%"><img src="Resources/STSegmentedControl01.png" width="25%" height="25%">
30+
<img src="Resources/STAlertView01.png" width="25%" height="25%"><img src="Resources/STAlertView02.png" width="25%" height="25%"><img src="Resources/STGradientButton01.png" width="25%" height="25%"><img src="Resources/STGradientView01.png" width="25%" height="25%"><img src="Resources/STHUD01.png" width="25%" height="25%"><img src="Resources/STHUD02.png" width="25%" height="25%"><img src="Resources/STMoveButton01.png" width="25%" height="25%"><img src="Resources/STPhoneTextField01.png" width="25%" height="25%"><img src="Resources/STProgressView01.png" width="25%" height="25%"><img src="Resources/STSegmentedControl01.png" width="25%" height="25%"><img src="Resources/STTimerButton01.png" width="25%" height="25%">
3131

3232

3333
## 1.STAlertView
@@ -156,3 +156,36 @@ segmentedControl.selectBlock = { (item) in
156156
}
157157
segmentedControl.currentIndex = 3
158158
```
159+
160+
## 9.STTimerButton
161+
162+
### Installing and Usage
163+
164+
```
165+
pod 'STKitSwift/STTimerButton'
166+
167+
```
168+
169+
### Example
170+
171+
```swift
172+
buttonCode.startCountDown(duration: 10) { (button, type, time) in
173+
print("button = \(button) type = \(type) time = \(time)")
174+
switch type {
175+
case .start:
176+
button.isEnabled = false
177+
button.setTitle(time.description + "s", for: .normal)
178+
button.backgroundColor = .gray
179+
case .ongoing:
180+
button.isEnabled = false
181+
button.setTitle(time.description + "s", for: .normal)
182+
button.backgroundColor = .gray
183+
case .finish:
184+
button.isEnabled = true
185+
button.setTitle("重新发送", for: .normal)
186+
button.backgroundColor = .red
187+
default:
188+
button.isEnabled = true
189+
}
190+
}
191+
```

Resources/STTimerButton01.png

120 KB
Loading

STKitSwiftDemo/STKitSwiftDemo/STTimerButton.swift renamed to STKitSwift/STTimerButton.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import UIKit
1010

11-
1211
public enum STTimerButtonType: Int {
1312
case none = -1 // no state
1413
case start = 0
@@ -21,9 +20,7 @@ public enum STTimerButtonType: Int {
2120

2221
public class STTimerButton: UIButton {
2322
// MARK: 1.lift cycle
24-
deinit {
25-
print("STTimerButton deinit")
26-
}
23+
2724
// MARK: 2.private methods
2825
public func startCountDown(duration time: Int, processBlock block: ((_ button: STTimerButton, _ type: STTimerButtonType, _ timerNumer: Int) -> Void)? = nil){
2926
duration = time

STKitSwiftDemo/STKitSwiftDemo.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
0466F64922CF531C0007D707 /* STTimerButtonController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0466F64822CF531C0007D707 /* STTimerButtonController.swift */; };
1313
04783DBC22CAE8870089AAB8 /* STPhoneTextFieldController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04783DBB22CAE8870089AAB8 /* STPhoneTextFieldController.swift */; };
1414
04783DC822CB01B70089AAB8 /* STGradientViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04783DC722CB01B70089AAB8 /* STGradientViewController.swift */; };
15-
0491946F22D2E88000709995 /* STTimerButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0491946E22D2E87F00709995 /* STTimerButton.swift */; };
1615
0492AF2322C9A6C000F73D31 /* STHUDController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0492AF2222C9A6C000F73D31 /* STHUDController.swift */; };
1716
0492AF3222C9C29700F73D31 /* STAlertController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0492AF3122C9C29700F73D31 /* STAlertController.swift */; };
1817
04EB3E0222CC2D270064DDF1 /* STSegmentedController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04EB3E0122CC2D270064DDF1 /* STSegmentedController.swift */; };
@@ -30,7 +29,6 @@
3029
0466F64822CF531C0007D707 /* STTimerButtonController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STTimerButtonController.swift; sourceTree = "<group>"; };
3130
04783DBB22CAE8870089AAB8 /* STPhoneTextFieldController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPhoneTextFieldController.swift; sourceTree = "<group>"; };
3231
04783DC722CB01B70089AAB8 /* STGradientViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STGradientViewController.swift; sourceTree = "<group>"; };
33-
0491946E22D2E87F00709995 /* STTimerButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STTimerButton.swift; sourceTree = "<group>"; };
3432
0492AF2222C9A6C000F73D31 /* STHUDController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STHUDController.swift; sourceTree = "<group>"; };
3533
0492AF3122C9C29700F73D31 /* STAlertController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STAlertController.swift; sourceTree = "<group>"; };
3634
04EB3E0122CC2D270064DDF1 /* STSegmentedController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STSegmentedController.swift; sourceTree = "<group>"; };
@@ -97,7 +95,6 @@
9795
04783DC722CB01B70089AAB8 /* STGradientViewController.swift */,
9896
04EB3E0122CC2D270064DDF1 /* STSegmentedController.swift */,
9997
04EB3E0522CC7E8B0064DDF1 /* STProgressController.swift */,
100-
0491946E22D2E87F00709995 /* STTimerButton.swift */,
10198
0466F64822CF531C0007D707 /* STTimerButtonController.swift */,
10299
6784886121B7CCFE0002FDF5 /* Main.storyboard */,
103100
6784886421B7CD000002FDF5 /* Assets.xcassets */,
@@ -237,7 +234,6 @@
237234
0492AF2322C9A6C000F73D31 /* STHUDController.swift in Sources */,
238235
04783DBC22CAE8870089AAB8 /* STPhoneTextFieldController.swift in Sources */,
239236
04783DC822CB01B70089AAB8 /* STGradientViewController.swift in Sources */,
240-
0491946F22D2E88000709995 /* STTimerButton.swift in Sources */,
241237
6784885E21B7CCFE0002FDF5 /* AppDelegate.swift in Sources */,
242238
04EB3E0222CC2D270064DDF1 /* STSegmentedController.swift in Sources */,
243239
);

STKitSwiftDemo/STKitSwiftDemo.xcworkspace/contents.xcworkspacedata

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

STKitSwiftDemo/STKitSwiftDemo/STTimerButtonController.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@ class STTimerButtonController: UIViewController {
2828
maker.centerX.equalToSuperview()
2929
maker.top.equalTo(buttonCode.snp.bottom).offset(20)
3030
}
31-
3231
actionTime()
3332
}
3433

3534
deinit {
3635
buttonCode.invalidate()
3736
buttonTime.invalidate()
38-
3937
print("--------- STTimerButtonController deinit ---------")
4038
}
4139
// MARK: 2.private methods
@@ -53,7 +51,7 @@ class STTimerButtonController: UIViewController {
5351

5452
// MARK: 3.event response
5553
@objc func actionCode(){
56-
buttonCode.startCountDown(duration: 3) { (button, type, time) in
54+
buttonCode.startCountDown(duration: 10) { (button, type, time) in
5755
print("button = \(button) type = \(type) time = \(time)")
5856
switch type {
5957
case .start:
@@ -71,7 +69,6 @@ class STTimerButtonController: UIViewController {
7169
default:
7270
button.isEnabled = true
7371
}
74-
7572
}
7673
}
7774

0 commit comments

Comments
 (0)