Andrej Andrej - 1 year ago 72
iOS Question

UIButton gets shown before title gets updated?

I'm trying to change the title of a hidden button and soon after I'd like to un-hide it (to show it). Here's the code:

recordButton.setTitle("Stop", forState: .Normal)
recordButton.hidden = false

The problem is that the button gets shown with his old title and only after that the new title appears. Maybe it takes 0.1 second, but it's noticeable and disturbing. Additionally I've checked and can confirm that the title's text is "Plain" (not "Attributed").

Am I missing something?

How to properly change the buttons title and then show it only when the title is already updated?

Should I make some verifications before calling
recordButton.hidden = false

Answer Source

Ensure that you are using UIButton with type UIButtonType.Custom

In a storyboard it can be set here: enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download