var button1 = UIButton(frame: CGRectMake(100, 200, 100, 40))
button1 .setTitle("first button", forState:UIControlState.Normal)
button1.addTarget(self, action: "firstSwift:", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(button1)
button1.backgroundColor=UIColor.yellowColor()
button1.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
func firstSwift(sender:UIButton)
{
println("第一个button的点击事件")
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/darongzi1314/article/details/46814273