UIButton setTitle doesn't work

The type of the sender should be UIButton, when creating the IBAction function. The sender is your button. The function is called when you tap on the button. You must use the function setTitle on the sender(your button).

@IBAction func buttonTouchedUpInside(sender: UIButton) { 
    sender.setTitle("buttonName", forState: .normal)
}

Swift 4:

Plain Title

The setTitle() method will work for titles that are "Plain" as defined in the button's Attributes inspector.

@IBAction func button(sender: UIButton) { 
     sender.setTitle("buttonName", for: .normal)
}

Attributed Title

The setTitle() method has no effect on a button's title if it's configured as "Attributed" in the Attributes inspector. To manage this situation, first get the attributed title from the button, then set the value.

@IBAction func button(sender: UIButton) { 
     let attributedTitle = sender.attributedTitle(for: .normal)
     attributedTitle?.setValue("buttonName", forKey: "string")
     sender.setAttributedTitle(attributedTitle, for: .normal)
}

In practically, if you use button from Storyboard or Xib file, and not clear button value in (Storyboard, Xib), than setTitle method doesn't work. If you cleared button value, setTitle method is work.