1

I have a button that contains different titles that depends on the app's circumstances. The problem is that every time it changes it happens with an unwanted animation. I change it using the next line of code:

self.nextLevelButton.setTitle("Next Level", forState: UIControlState.Normal)

I have tried:

self.nextLevelButton.layoutifneeded() 

and:

uiview.setAnimaionsEnabled(false)
self.nextLevelButton.setTitle("Next Level", forState: UIControlState.Normal)
uiview.setAnimaionsEnabled(true)

None of the above is working.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Ivan
  • 181
  • 11
  • I saw that question, nevertheless it is for objective C and the solutions for them aren't working for swift. – Ivan Dec 09 '15 at 00:39
  • It is trivial to covert to swift - UIView.performWithoutAnimation { () -> Void in self.myButton.setTitle(newTitle, forState: .Normal) self.myButton.layoutIfNeeded() } I just tested this and it is fine. – Paulw11 Dec 09 '15 at 00:40
  • I have added a Swift equivalent answer. The `setAnimationsEnabled` false/true version also works in Swift – Paulw11 Dec 09 '15 at 00:44
  • I detected the problem, the uibutton must be in custom mode and not in system. – Ivan Dec 09 '15 at 21:22

0 Answers0