Search code examples
iosswiftuibuttonuilabeliboutlet

UIButton Outlet Set title Swift


I have set up an outlet as follows using a storyboard:

@IBOutlet var completeButton: UIButton!



self.completeButton.titleLabel = UIFont (name: standardFont, size: 22.0)

give the error cannot assign to the result of this expression.

Simple task but can't seem to get round this in swift.


Solution

  • You are missing out the font property and titleLabel needs to be unwrapped. Try the following:

    self.completeButton.titleLabel!.font = UIFont.systemFontOfSize(22.0)