                 
                 dispatch_async(dispatch_get_main_queue(), { () -> Void in
                     self.backgroundColor = self.enableColor
-                    self.setTitle(self.originTitle, forState: .Normal)
+                    self.setTitle(self.finishTitle ?? self.originTitle, forState: .Normal)
                     self.userInteractionEnabled = true
                 })
+                
+                if let theDelegate = self.delegate {
+                    if let theMethod = theDelegate.timeDidRun?() {
+                        theMethod
+                    }
+                }
+                
             }else{
-                let timeStr = String(timeOut)+self.timeRunningUnit
+                let timeStr = String(timeOut)+(self.timeRunningUnit ?? "")
                 
                 dispatch_async(dispatch_get_main_queue(), { () -> Void in
                     self.backgroundColor = self.disableColor

                    self.userInteractionEnabled = false
                })
                
                timeOut--
            }
        }
        
        dispatch_resume(timer)
        
    }
    
}


import UIKit

@objc public protocol TLTimeButtonDelegate {
    
    optional func timeWillRun()
    optional func timeRunning(currentTime: Int)
    optional func timeDidRun()
}

public class TLTimeButton: UIButton {
    
    var timeLine: Int = 60 //倒计时初始时间
    var originTitle: String! //原始文案显示
    var finishTitle: String? //倒计时完成文案，如果未指定，则显示originTitle文案
    var timeRunningUnit: String? //倒计时时数字后面的单位，如果为空则不显示
    var enableColor: UIColor! //使能时的颜色
    var disableColor: UIColor! //不使能时的颜色
    
    weak var delegate: TLTimeButtonDelegate?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
    }
    
    required public init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    convenience public init(frame: CGRect, timeLine: Int, originTitle: String, finishTitle: String?, timeRunningUnit: String?, enableColor: UIColor, disableColor: UIColor) {
        self.init(frame: frame)
        
        self.timeLine = timeLine
        self.originTitle = originTitle
        self.finishTitle = finishTitle
        self.timeRunningUnit = timeRunningUnit
        self.enableColor = enableColor
        self.disableColor = disableColor
        
        styleInit()
    }
    
    private func styleInit() {
        self.userInteractionEnabled = true
        self.backgroundColor = enableColor
        self.setTitle(originTitle, forState: .Normal)
        self.addTarget(self, action: "clickButton:", forControlEvents: .TouchUpInside)
    }
    
    private func clickButton(sender: TLTimeButton){
        
        if let theDelegate = delegate {
            if let theMethod = theDelegate.timeWillRun?() {
                theMethod
            }
        }
        
        startWithTime()
    }
    
    private func startWithTime() {
        
        var timeOut = timeLine
        
