Swift学习:动态生成圆角矩形UIButton

let btn_fontSizeMinus = UIButton(type: .roundedRect)

btn_fontSizeMinus.frame = CGRect(x: 0, y: 10, width: 70, height: 30)

btn_fontSizeMinus.setTitle("Aa-", for: .normal)

btn_fontSizeMinus.setTitleColor(.white, for: .normal)

btn_fontSizeMinus.layer.cornerRadius = 5

btn_fontSizeMinus.layer.borderWidth = 1

btn_fontSizeMinus.layer.borderColor = UIColor.white.cgColor

btn_fontSizeMinus.addTarget(self, action: #selector(btn_fontSizeMinusClick), for: .touchUpInside)

self.viewReadSet.addSubview(btn_fontSizeMinus)

以上为动态生成按钮 btn_fontSizeMinus 的过程。

你可能感兴趣的:(Swift学习:动态生成圆角矩形UIButton)