var btn9:UIButton = UIButton(frame: CGRect(x: 50,y: 420,width: 100,height: 35))
btn9.backgroundColor = UIColor.whiteColor()
btn9.setTitle("边框按钮",forState: UIControlState.Normal)
btn9.setTitleColor(UIColor.blackColor(),forState: UIControlState.Normal)
btn9.layer.borderColor = UIColor.blackColor().CGColor
btn9.layer.borderWidth = 1
btn9.layer.cornerRadius = 5
给按钮添加图片:
btn3.setImage(UIImage(named: "btn1"),forState: UIControlState.Normal)
添加点击事件
logout_bt.addTarget(self,action:"logoutAction",forControlEvents: .TouchUpInside)
写对应的方法
func logoutAction(){
print("退出账号")
}
shareBt.alpha = 0.0//隐藏按钮
shareBt.enabled = false//让按钮不能点击
学习 :http://zhidao.baidu.com/link?url=2fAetLQQjf0hrzIHOLK1KcdO472ORvvUW_fL--H_pP3zyt1qTdPdroYYVDJ9o89_mF80V5PG80JwrI0ofdUPJ_1XonkV8SXCbfKR5GrXajy