I am trying to set an attributed string to a button.
The definition of this function in swift is
func setAttributedTitle(_ title: NSAttributedString!,
forState state: UIControlState)
so I thought that I would have to type it as
myButton.setAttributedTitle(title:attrString, forState: UIControlState.Normal)
but correct
myButton.setAttributedTitle(attrString, forState: UIControlState.Normal)
Why should I put forState:, but not title? I do not understand this.
And by the way, what is the meaning of this underline in the definition of func?
source
share