您的代码应如下所示
let image = UIImage(named: "name") as UIImage?let button = UIButton(type: UIButtonType.Custom) as UIButtonbutton.frame = CGRectMake(100, 100, 100, 100)button.setImage(image, forState: .Normal)button.addTarget(self, action: "btnTouched:", forControlEvents:.TouchUpInside)self.view.addSubview(button)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)