swift创建按钮的两种方法

来源:互联网 发布:家庭装修软件 编辑:程序博客网 时间:2024/05/21 09:10

按钮的创建

   var 按钮 = UIButton(frame: CGRectMake(100, 100, 100, 35))        按钮.backgroundColor = UIColor.magentaColor()        按钮.addTarget(self, action: "buttonAction", forControlEvents: UIControlEvents.TouchUpInside)        按钮.setTitle("按钮", forState: UIControlState.Normal)        self.view.addSubview(按钮)                        var btn=UIButton.buttonWithType(UIButtonType.ContactAdd) as? UIButton        btn!.frame =  CGRectMake(100, 150, 100, 35)        self.view.addSubview(btn!)


0 0
原创粉丝点击