During custom segue transition, view's navigation bar items are misplaced

丶灬走出姿态 提交于 2019-12-12 10:02:52

问题


I've got a custom segue that uses the UIViewAnimationOptionTransitionFlipFromLeft to transition between views.

When the new view comes on screen, there is a brief but discernible 'blink' caused by the Navigation Bar elements jumping from a left-aligned state to their appropriate positions. Following is a screenshot captured near the very end of the transition:


You can see that the title and two bar button items are left aligned; completely out of place from where they will eventually rest.

Following is a screenshot captured after the transition has completed:


Here the buttons and title are positioned correctly. During the instant between the first and second images, the icons blink into position.

The view is setup in storyboard. The view is not part of a UINavigationController hierarchy, so the navigation bar and its items are manually created on the view via the attributes inspector, 'Simulated Metrics' -> 'Top Bar: Translucent Navigation Bar'.

How can I force the navigation bar items to be correctly positioned when they first appear during the transition?

Thank you in advance! :)


回答1:


Got it! I found that using the [UIView performWithoutAnimation:^{}] block inside of transitionWithView solved this problem:

[UIView transitionWithView:src.navigationController.view duration:0.2
                   options:UIViewAnimationOptionTransitionFlipFromLeft
                animations:^{
                                [UIView performWithoutAnimation:^{
                                    [navController setViewControllers:[NSArray arrayWithObject:dst] animated:NO];
                                }];
                            }
                completion:nil];


来源:https://stackoverflow.com/questions/26127915/during-custom-segue-transition-views-navigation-bar-items-are-misplaced

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