Navigation bar gets adjusted after calling completeTransition: in custom transition

后端 未结 4 1001
温柔的废话
温柔的废话 2020-12-16 12:34

My goal is to provide zooming modal transition from for the user from a view similar as springboard icons zoom in when launching apps.

The presented view controller

4条回答
  •  一整个雨季
    2020-12-16 13:04

    I've found a solution, although pretty hacky. I have to manually adjust the navigation bar frame before the animation starts:

    if (self.reverse) {
        [container insertSubview:toViewController.view belowSubview:fromViewController.view];
    } else {
        toViewController.view.transform = transform;
        [container addSubview:toViewController.view];
    
        // fix navigation bar position to prevent jump when completeTransition: is called
        if ([toViewController isKindOfClass:[UINavigationController class]]) {
            UINavigationController* navigationController = (UINavigationController*) toViewController;
            UINavigationBar* bar = navigationController.navigationBar;
            CGRect frame = bar.frame;
            bar.frame = CGRectMake(frame.origin.x, frame.origin.y + 20.0f, frame.size.width, frame.size.height);
        }
    }
    

提交回复
热议问题