自定义button的init方法

来源:互联网 发布:scopus数据库简介 编辑:程序博客网 时间:2024/05/22 23:58

class WBButton: UIButton {

    convenienceinit(text:String , fontSize:CGFloat , normalColor:UIColor , highlightedColor:UIColor , backgroundImageName:String) {

        self.init()

        self.setTitle(text, for: .normal)

        self.titleLabel?.font =UIFont.boldSystemFont(ofSize: fontSize)

        self.setTitleColor(normalColor, for: .normal)

        self.setTitleColor(highlightedColor, for: .highlighted)

        self.setBackgroundImage(UIImage(named: backgroundImageName), for: .normal)

    }

}

0 0
原创粉丝点击