1

I encountered the problem, can't find a good solution so far.

After some certain actions I want to change the background color of my self.view with animation. So I do something like this:

 [UIView animateWithDuration:5.0 delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
            self.view.backgroundColor = [UIColor orangeColor];
        } completion:^(BOOL finished) {
            self.backgroundColor = self.view.backgroundColor;
        }];

And I want this animation to be slow and easy, that's why it can be likfe 3-5 seconds, not just a quick switch form one to another.

The problem is that if I make it on the Main thread it makes my app completely unresponsive for these 3-5 seconds while the animation is performing. If I make it on the background thread I have a lot of problem, which is expected.

Is there any good solution how to slowly update background color with animation without freezing the screen?

Thanks!

1 Answer 1

2

You need to use UIViewAnimationOptionAllowUserInteraction option instead of UIViewAnimationOptionCurveEaseOut to allow user interaction.

[UIView animateWithDuration:5.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
    self.view.backgroundColor = [UIColor orangeColor];
} completion:^(BOOL finished) {
    self.backgroundColor = self.view.backgroundColor;
}];
2
  • 1
    It doesn't have to be "instead of", you can "or" the two options together.
    – rdelmar
    Apr 6, 2014 at 16:03
  • @rdelmar - Yeah, that's what I did. Thanks anyway
    – titicaca
    Apr 6, 2014 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.