The problem is in the controller.

I need to do this: change the UI , sleep 2 seconds, change the UI again. In fact, it happens that we sleep 2 seconds, and only then does the UI change.

That is, in the code:

[button1 setBackgtound ... ] [NSTread sleepForTimeInterval: 2] [button2 setBackground ...] 

And at startup, it waits 2 seconds first, and then changes both.

    1 answer 1

    Better not to sleep the main thread, because it blocks user-events and UI changes. Postpone updating button2 for 2 seconds using GCD:

     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ [button2 setBackground ...]; }); 
    • one
      Nastya, thank you very much! Everything works as it should - Denis Kovzan