// // UIButton+Extension.swift // zc // // Created by wyp on 2020/10/20. // Copyright © 2020 wyp. All rights reserved. // import UIKit public extension UIButton { func borderColor(_ color: UIColor, cornerRadius: CGFloat = 4) { layoutIfNeeded() // let button = UIButton() self.frame = self.bounds self.layer.cornerRadius = cornerRadius self.layer.borderWidth = 1 self.layer.borderColor = color.cgColor self.layer.masksToBounds = true // self.titleLabel?.font = font self.titleLabel?.textAlignment = .center // self.setTitleColor(color, for: .normal) } func setColor(radio: CGFloat, color: UIColor, borderColor: UIColor, textColor: UIColor, text: String) { self.layer.borderWidth = 0.5 self.layer.borderColor = borderColor.cgColor self.backgroundColor = color self.setTitle(text, for: .normal) self.setTitleColor(textColor, for: .normal) self.layer.cornerRadius = radio } }