mport UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//创建Button类型:system,custom,contactAdd,(detailDisclosure,infoDark,infoLight效果一样),roundedRect
let button = UIButton(type: .custom)
//设置Button位置
button.frame = CGRect(x: 150, y: 250, width: 100, height: 100)
//设置按钮文字
button.setTitle("按钮", for: .highlighted)//有三种状态:普通状态:normal,触摸状态:hightlighted禁用状态:disabled
//设置按钮文字
button.setTitleColor
Swift - UIButton
最新推荐文章于 2021-02-22 20:56:13 发布