swift4中的runtime机制的initialize()这个方法已经被废弃了 所以需要吧自己写的那个方法,在Appdelegate 中调用此方法
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//在此处调用
UIButton.initializeMethod()
// Override point for customization after application launch.
return true
}
......
}
import UIKit
public extension UIButton{
public struct AssociatedKeys{
static var defaultInterval : TimeInterval = 5 //间隔时间<