How to change the font size of a button in Xcode

Hi

I am in Xcode in the interface builder storyboard trying to make a tic-tac-toe game. In an action I wanted when the user presses a button an X appears at a certain font size. I have looked for a long time around the internet and still couldn't find anything. I will be forever grateful if you could help me 😁.

 @IBAction func testX(_ sender: UIButton) {
sender.titleLabel?.font = [UIFont withSize(75.0)];
}

I tried this it doesn't work.

Problem is because you have it in the IBAction…

Have a look here on how to achieve it with configuration:

https://stackoverflow.com/questions/70977386/how-to-set-different-font-size-for-uibutton-when-it-is-pressed

You can also simply work around the issue with a dispatch:

     @IBAction func testX(_ sender: UIButton) {
          DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1)  { 
               sender.titleLabel?.font = sender.titleLabel?.font.withSize(75)  // really HUGE
          }
    }

Thank you so much. This is huge relief I was searching for hours! I am still testing it out. Very appreciated!

How to change the font size of a button in Xcode
 
 
Q