Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push animation without shadows and blackouts

I have a simple iOS NavigationController based application. Two UICollectionViews, one after another. If element on "first collection" was clicked, the "second collection" will be opened. Quite simple.

Important note:

"Both UICollectionViews have transparent background. General background color for navigationController is used. (Inherited class from UINavigationController)"

The problem: If understood it right, push method of NavigationController works according to algorithm:

  1. Pushing view is created.
  2. Transparent gray overlay is created over pushing view.
  3. NavigationController pushes the view with standard animation. (Gray overlay still there)
  4. Gray overlay disappears.

(If pushing view has transparent background, a gray vertical line is visible)

Screenshot

Next step: I've tried to solve this problem by overriding push method. Here's what I've got:

- (void)pushViewController:(UIViewController *)viewController 
                           animated:(BOOL)animated
{
    CATransition *transition = [CATransition animation];
    transition.duration = 0.45;
    transition.timingFunction = [CAMediaTimingFunction 
           functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromRight;
    transition.fillMode = kCAFillModeForwards;
    transition.delegate = self;
    [self.view.layer addAnimation:transition forKey:nil];

    [super pushViewController:viewController animated:animated];
}

This way creates its own push animation, but there were another standard animations used, which I can't remove. (Blackout on presenting and hiding views)

Screenshots_1_and_2

Question: "How can I push ViewController, without fading, blackout, and other animation filters?"

Solutions with theme names (on stackoverflow.com)

  • iOS 7 UINavigationController Push animation shadow
  • iOS 7 shows black background in custom animation for Navigation

Don't work.

like image 241
Evghenii Orenciuc Avatar asked Apr 30 '14 19:04

Evghenii Orenciuc


1 Answers

Don't override the push method. iOS7 allows you to provide animation controllers for custom transitions. See here for more details.

like image 74
Léo Natan Avatar answered Oct 21 '22 21:10

Léo Natan