UIButton 有一个枚举
UIButtonType
专门用来指定button的类型
这里我们尝试一下接种类型看看效果、
//按钮的几种类型
//系统默认button
let btn1=UIButton.buttonWithType(UIButtonType.System) as! UIButton
btn1.frame=CGRectMake(20, 50, 320, 36);
btn1.setTitle("SystemButton", forState: UIControlState.Normal);
self.view.addSubview(btn1);
//所有属性需要自定义,否则字体颜色为白色
let btn2=UIButton.buttonWithType(UIButtonType.Custom) as! UIButton
btn2.frame=CGRectMake(20, 100, 320, 36);
btn2.setTitle("CustomButton", forState: UIControlState.Normal);
btn2 .setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
self.view.addSubview(btn2);
//以下为几种带图标的button
let btn3=UIButton.buttonWith