swift uibutton添加了事件怎么直接执行了
1个回答
展开全部
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的点击事件")
}
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的点击事件")
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询