let signButton = UIButton.init()
signButton.setImage(UIImage.init(named: "sign_icon"), for: UIControlState.normal) //按钮图标
signButton.titleLabel?.font = UIFont.systemFont(ofSize: 14) //文字大小
signButton.setTitle("签到", for: UIControlState.normal) //按钮文字
signButton.setTitleColor(UIColor.white, for: UIControlState.normal) //文字颜色
signButton.setBackgroundImage(UIImage.init(named: "sign_bg"), for: UIControlState.normal) //按钮背景图片
signButton.addTarget(self, action: #selector(signButtonAction), for: UIControlEvents.touchUpInside)
self.contentView.addSubview(signButton)
关于swift中UIButton中的一些属性及操作
最新推荐文章于 2024-09-11 19:47:57 发布