import UIKit
typealias tapHandler = (sender:UIButton) -> ()
class BaseUIButton: UIButton {
var heandler: tapHandler!
class func button(frame:CGRect,title:String?,fontFloat:CGFloat,image:UIImage?,color:UIColor?,handler:tapHandler)-> (UIButton){
let button = BaseUIButton()
button.frame = frame
button.titleLabel?.textAlignment = NSTextAlignment.Center
button.titleLabel?.font = UIFont.systemFontOfSize(fontFloat)
button.backgroundColor = color
button.setTitle(title, forState: UIControlState.Normal)
button.setImage(image, forState: UIControlState.Normal)
button.heandler = handler
///點(diǎn)擊
button.addTarget(button, action: #selector(btnClick(_:)), forControlEvents: UIControlEvents.TouchUpInside)
return button
}
func btnClick(btn:UIButton){
///調(diào)用block
heandler(sender: btn)
}
}
-
看我那么可愛n(≧▽≦)n
- 關(guān)注我的微薄 (梁同桌):http://weibo.com/tongrenyinsheng
- 網(wǎng)站(同人音聲) http://www.tongrenyinsheng.com
- ios 個(gè)人寫的app (同人音聲)ASMR音樂