一直觉得自己写的不是技术,而是情怀,一个个的教程是自己这一路走来的痕迹。靠专业技能的成功是最具可复制性的,希望我的这条路能让你们少走弯路,希望我能帮你们抹去知识的蒙尘,希望我能帮你们理清知识的脉络,希望未来技术之巅上有你们也有我。
Swift 项目底层框架(万能)
使用场景:
当时写写项目的时候用户进入确认订单后退出,变成待支付,计算用户未付款的时候,超过时间后取消订单。
效果
使用
import UIKit
class ViewController: UIViewController {
let btn = UIButton(frame: CGRect(x: 150, y: 150, width: 200, height: 30))
let currentTimeStamp = Calendar.getTimeStamp()
let countdown = CountDownManager()//创建
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.white
view.addSubview(btn)
btn.titleLabel?.textColor = UIColor.blue
btn.titleLabel?.font = UIFont.systemFont(ofSize: 14)
btn.backgroundColor = UIColor.orange
btn.setTitle("fenghanxu", for: .normal)
btn.add(for: .touchUpInside) {
// 使用
self.countdown.clockwiseHasPasstime(withStratTimeStamp: self.currentTimeStamp , adjust: 0) { [weak self] (showTime) in
guard let base = self else { return }
guard let time = showTime else { return }
base.btn.setTitle("您连续拒单时长: " + time, for: .normal)
}
}
//不用的时候记得 销毁时间
countdown.destoryTimer()
}
}