How to change button image in swift?

后端 未结 8 2322
一生所求
一生所求 2021-02-10 04:16

I am working on an app which has a button. The button has no text, image or background.

So what I want to do is to give it an image in the viewDidLoad function.

8条回答
  •  温柔的废话
    2021-02-10 04:37

    let button = UIButton(type: .Custom)
    let image = UIImage(named:"redTap")?.imageWithRenderingMode(.AlwaysTemplate)
    button.setImage(image, forState: .Normal)
    button.tintColor = UIColor.redColor()
    

提交回复
热议问题