Push animation without shadows and blackouts

一笑奈何 提交于 2019-12-10 14:25:46

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/23396777/push-animation-without-shadows-and-blackouts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!