Question

I am trying to flip transition on the same ViewController, I have a button for trigger transition. I want to change theme color when i press to button via flip transition.

i used this code part:

- (IBAction)changeThemeButtonTapped:(id)sender
{

int tempThemeColor = [[NSUserDefaults standardUserDefaults]integerForKey:@"themeColor"];


if (tempThemeColor == 10) {

    [self loadTheme];
    [UIView transitionFromView:self.view

                        toView:self.view

                      duration:1.0

                       options:UIViewAnimationOptionTransitionFlipFromLeft

                    completion:^(BOOL finished) {
                        NSLog(@"finished");

    }];

}else{

    [self loadTheme];
    [UIView transitionFromView:self.view

                        toView:self.view

                      duration:1.0

                       options:UIViewAnimationOptionTransitionFlipFromRight

                    completion:^(BOOL finished) {
                        NSLog(@"finished");

    }];

}  
}

when i press to button, view turns to black. Is there any way to do? What is my mistake? Thank you for your answer and interest.

Was it helpful?

Solution

I found my question's answer.

if (tempThemeColor == 10) {

    [self loadTheme];

    [UIView transitionWithView:self.view
                      duration:1.0
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    animations:^{

                    } completion:^(BOOL finished) {

                    }];

}else{

    [self loadTheme]; 
    [UIView transitionWithView:self.view
                      duration:1.0
                       options:UIViewAnimationOptionTransitionFlipFromRight
                    animations:^{

                    } completion:^(BOOL finished) {

                    }];

}

OTHER TIPS

Before doing animation try to change the window/super view of the view's color

if (self.view.superview) {

    self.view.superview.backgroundColor = [UIColor whiteColor];

}


 self.view.window.backgroundColor = [UIColor whiteColor];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top